mirror of
git://git.9front.org/plan9front/plan9front
synced 2025-01-12 11:10:06 +00:00
libauthsrv: import better passtodeskey() function (from drawterm)
This commit is contained in:
parent
6940bbc50b
commit
19c89f5212
1 changed files with 6 additions and 6 deletions
|
@ -9,14 +9,14 @@ passtodeskey(char key[DESKEYLEN], char *p)
|
|||
uchar buf[PASSWDLEN], *t;
|
||||
int i, n;
|
||||
|
||||
n = strlen(p);
|
||||
if(n >= PASSWDLEN)
|
||||
n = PASSWDLEN-1;
|
||||
memset(buf, ' ', 8);
|
||||
t = buf;
|
||||
strncpy((char*)t, p, n);
|
||||
t[n] = 0;
|
||||
n = strlen(p);
|
||||
if(n >= sizeof(buf))
|
||||
n = sizeof(buf)-1;
|
||||
memmove(buf, p, n);
|
||||
buf[n] = 0;
|
||||
memset(key, 0, DESKEYLEN);
|
||||
t = buf;
|
||||
for(;;){
|
||||
for(i = 0; i < DESKEYLEN; i++)
|
||||
key[i] = (t[i] >> i) + (t[i+1] << (8 - (i+1)));
|
||||
|
|
Loading…
Reference in a new issue