Hi,
the listed program fails:
Take a String e.g. "blue123" and "glue123" - the first character does not change the hash!
You should exchange the line: wint += (decoded[i]) * (i) ^ (i);
with wint += decoded[i] * (i+1)^(i+1);
to get the origin algorithm of vxworks!
By the way, this vxworks hash is insecure and you'll find several collisions, it's easy to find passwords with known hash. Please use any other actual hash algorithmn - do not use vxworks' hashs any more!
BR
Thomas Kuschel
htpasswd -nd blue1234
openssl passwd -crypt blue1234
nope
maybe they use a salt...
i am not an C guru, but it's works.
this program generate passwords for the Motorola CM Telnet Access.
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
unsigned int i;
unsigned int pwint = 0;
unsigned int magic = 31695317;
char decoded[40];
char encoded[10];
strcpy(decoded, argv[1]);
if (strlen(decoded) < 8 || strlen(decoded) > 40)
{
printf ("password must be 8-40 characters.\n");
return 1;
}
for (i = 0; i < strlen(decoded); i++)
pwint += (decoded[i]) * (i) ^ (i);
sprintf (encoded, "%u", (pwint * magic));
for (i = 0; i < strlen(encoded); i++)
{
if (encoded[i] < '3')
encoded[i] = encoded[i] + '!';
if (encoded[i] < '7')
encoded[i] = encoded[i] + '/';
if (encoded[i] < '9')
encoded[i] = encoded[i] + 'B';
}
printf ("%s\n", encoded);
return 0;
}
Hi,
the listed program fails:
Take a String e.g. "blue123" and "glue123" - the first character does not change the hash!
You should exchange the line:
wint += (decoded[i]) * (i) ^ (i);
with
wint += decoded[i] * (i+1)^(i+1);
to get the origin algorithm of vxworks!
By the way, this vxworks hash is insecure and you'll find several collisions, it's easy to find passwords with known hash. Please use any other actual hash algorithmn - do not use vxworks' hashs any more!
BR
Thomas Kuschel