1 /* 2 * hostapd - Plaintext password to NtPasswordHash 3 * Copyright (c) 2005, Jouni Malinen <j (at) w1.fi> 4 * 5 * This software may be distributed under the terms of the BSD license. 6 * See README for more details. 7 */ 8 9 #include "includes.h" 10 11 #include "common.h" 12 #include "crypto/ms_funcs.h" 13 14 15 int main(int argc, char *argv[]) 16 { 17 unsigned char password_hash[16]; 18 size_t i; 19 char *password, buf[64], *pos; 20 21 if (argc > 1) 22 password = argv[1]; 23 else { 24 if (fgets(buf, sizeof(buf), stdin) == NULL) { 25 printf("Failed to read password\n"); 26 return 1; 27 } 28 buf[sizeof(buf) - 1] = '\0'; 29 pos = buf; 30 while (*pos != '\0') { 31 if (*pos == '\r' || *pos == '\n') { 32 *pos = '\0'; 33 break; 34 } 35 pos++; 36 } 37 password = buf; 38 } 39 40 if (nt_password_hash((u8 *) password, strlen(password), password_hash)) 41 return -1; 42 for (i = 0; i < sizeof(password_hash); i++) 43 printf("%02x", password_hash[i]); 44 printf("\n"); 45 46 return 0; 47 } 48