Sync usage with man page.
[netbsd-mini2440.git] / dist / wpa / hostapd / nt_password_hash.c
blob9df307d54a84f438484b43cca84d245ed9b215eb
1 /*
2 * hostapd - Plaintext password to NtPasswordHash
3 * Copyright (c) 2005, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
15 #include "includes.h"
17 #include "common.h"
18 #include "ms_funcs.h"
21 int main(int argc, char *argv[])
23 unsigned char password_hash[16];
24 size_t i;
25 char *password, buf[64], *pos;
27 if (argc > 1)
28 password = argv[1];
29 else {
30 if (fgets(buf, sizeof(buf), stdin) == NULL) {
31 printf("Failed to read password\n");
32 return 1;
34 buf[sizeof(buf) - 1] = '\0';
35 pos = buf;
36 while (*pos != '\0') {
37 if (*pos == '\r' || *pos == '\n') {
38 *pos = '\0';
39 break;
41 pos++;
43 password = buf;
46 nt_password_hash((u8 *) password, strlen(password), password_hash);
47 for (i = 0; i < sizeof(password_hash); i++)
48 printf("%02x", password_hash[i]);
49 printf("\n");
51 return 0;