23 RCSID(
"$Id: d6a20dccf25084ec877e38e59b2daf185cb4bbbb $")
25 #include <freeradius-devel/libradius.h>
26 #include <freeradius-devel/md4.h>
27 #include <freeradius-devel/md5.h>
28 #include <freeradius-devel/sha1.h>
34 static char const hex[] =
"0123456789ABCDEF";
39 static void tohex (
unsigned char const *src,
size_t len,
char *dst)
42 for (i=0; i<len; i++) {
43 dst[(i*2)] = hex[(src[i] >> 4)];
44 dst[(i*2) + 1] = hex[(src[i]&0x0F)];
49 static void ntpwdhash(uint8_t *out,
char const *password)
52 uint8_t ucs2_password[512];
54 len =
fr_utf8_to_ucs2(ucs2_password,
sizeof(ucs2_password), password, strlen(password));
62 int main (
int argc,
char *argv[])
70 fprintf(stderr,
"LM Hash \tNT Hash\n");
71 fprintf(stderr,
"--------------------------------\t--------------------------------\n");
73 for (i = 1; i < argc; i++ ) {
74 strlcpy(password, argv[i],
sizeof(password));
76 if (l && password[l-1] ==
'\n') password [l-1] = 0;
78 tohex (hash, 16, lmpass);
80 tohex (hash, 16, ntpass);
81 printf(
"%s\t%s\n", lmpass, ntpass);
void smbdes_lmpwdhash(char const *password, uint8_t *lmhash)
int main(int argc, char *argv[])
void fr_md4_calc(uint8_t out[MD4_DIGEST_LENGTH], uint8_t const *in, size_t inlen)
Calculate the MD4 hash of the contents of a buffer.
static unsigned int hash(char const *username, unsigned int tablesize)
static void tohex(unsigned char const *src, size_t len, char *dst)
ssize_t fr_utf8_to_ucs2(uint8_t *out, size_t outlen, char const *in, size_t inlen)
Convert UTF8 string to UCS2 encoding.
static void ntpwdhash(uint8_t *out, char const *password)
size_t strlcpy(char *dst, char const *src, size_t siz)