Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

nt_password_hash.c 1.1KB

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