diff options
author | Luke Leighton <lkcl@samba.org> | 1998-05-07 19:59:32 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1998-05-07 19:59:32 +0000 |
commit | abe261b2f5ea7036e7be6230876176d134ef4ee4 (patch) | |
tree | 9c6afefcf6e77caf45efafa6739bf39195dcb188 /source/lib/util.c | |
parent | 1fd8d12ca414066acec71b33eb8a13e16c2acd3a (diff) | |
download | samba-abe261b2f5ea7036e7be6230876176d134ef4ee4.tar.gz samba-abe261b2f5ea7036e7be6230876176d134ef4ee4.tar.xz samba-abe261b2f5ea7036e7be6230876176d134ef4ee4.zip |
moving gethexpwd into util.c, because it's used in both smbpass.c and ldap.c
Diffstat (limited to 'source/lib/util.c')
-rw-r--r-- | source/lib/util.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/lib/util.c b/source/lib/util.c index 24161108579..2f637e14955 100644 --- a/source/lib/util.c +++ b/source/lib/util.c @@ -4965,3 +4965,30 @@ char *dom_sid_to_string(DOM_SID *sid) DEBUG(7,("dom_sid_to_string returning %s\n", sidstr)); return sidstr; } + +/************************************************************* + Routine to get the next 32 hex characters and turn them + into a 16 byte array. +**************************************************************/ +int gethexpwd(char *p, char *pwd) +{ + int i; + unsigned char lonybble, hinybble; + char *hexchars = "0123456789ABCDEF"; + char *p1, *p2; + + for (i = 0; i < 32; i += 2) { + hinybble = toupper(p[i]); + lonybble = toupper(p[i + 1]); + + p1 = strchr(hexchars, hinybble); + p2 = strchr(hexchars, lonybble); + if (!p1 || !p2) + return (False); + hinybble = PTR_DIFF(p1, hexchars); + lonybble = PTR_DIFF(p2, hexchars); + + pwd[i / 2] = (hinybble << 4) | lonybble; + } + return (True); +} |