diff options
author | Sam Leffler <sam@FreeBSD.org> | 2009-03-01 22:10:07 +0000 |
---|---|---|
committer | Sam Leffler <sam@FreeBSD.org> | 2009-03-01 22:10:07 +0000 |
commit | b2cbddbd4361766d55c5f9dae81f71f44577bb6a (patch) | |
tree | 372b16f9e6ccba7284b53135005cc85cc6545185 /hostapd/nt_password_hash.c | |
parent | 514fff2b7c1f2e25e5c0611b598797f32aff1042 (diff) | |
parent | 22188e6ab4f02f981de3b9f228a40b1e8f98e6a1 (diff) |
import wpa_supplicant+hostapd 0.6.8vendor/wpa/0.6.8
Notes
Notes:
svn path=/vendor/wpa/dist/; revision=189251
svn path=/vendor/wpa/0.6.8/; revision=189252; tag=vendor/wpa/0.6.8
Diffstat (limited to 'hostapd/nt_password_hash.c')
-rw-r--r-- | hostapd/nt_password_hash.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/hostapd/nt_password_hash.c b/hostapd/nt_password_hash.c new file mode 100644 index 000000000000..9df307d54a84 --- /dev/null +++ b/hostapd/nt_password_hash.c @@ -0,0 +1,52 @@ +/* + * hostapd - Plaintext password to NtPasswordHash + * Copyright (c) 2005, Jouni Malinen <j@w1.fi> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Alternatively, this software may be distributed under the terms of BSD + * license. + * + * See README and COPYING for more details. + */ + +#include "includes.h" + +#include "common.h" +#include "ms_funcs.h" + + +int main(int argc, char *argv[]) +{ + unsigned char password_hash[16]; + size_t i; + char *password, buf[64], *pos; + + if (argc > 1) + password = argv[1]; + else { + if (fgets(buf, sizeof(buf), stdin) == NULL) { + printf("Failed to read password\n"); + return 1; + } + buf[sizeof(buf) - 1] = '\0'; + pos = buf; + while (*pos != '\0') { + if (*pos == '\r' || *pos == '\n') { + *pos = '\0'; + break; + } + pos++; + } + password = buf; + } + + nt_password_hash((u8 *) password, strlen(password), password_hash); + for (i = 0; i < sizeof(password_hash); i++) + printf("%02x", password_hash[i]); + printf("\n"); + + return 0; +} |