Add simple algorithm for converting result hash to password

This commit is contained in:
Chris Oei 2012-09-03 13:55:29 -07:00
parent b3d2d92c81
commit 395b11b807
6 changed files with 80 additions and 3 deletions

18
lib/util/hashtopass.c Normal file
View file

@ -0,0 +1,18 @@
#include "hashtopass.h"
void hashtopass(char* p, size_t len, uint8_t* key)
{
char* lowers = "abcdefghijklmnopqrstuvwxyz";
char* uppers = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char* numerals = "0123456789";
char* allchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
p[0] = lowers[key[0] % 26];
p[1] = numerals[key[1] % 10];
p[2] = uppers[key[2] % 26];
size_t i;
for (i = 3; i < len; i++)
p[i] = allchars[key[i] % (26 + 26 + 10)];
p[len] = '\0';
}

12
lib/util/hashtopass.h Normal file
View file

@ -0,0 +1,12 @@
#include "scrypt_platform.h"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include "warn.h"
void hashtopass(char* p, size_t len, uint8_t* key);