Skip to content

Commit

Permalink
test a few rounds of the hashPassword function. looks to be buggy rig…
Browse files Browse the repository at this point in the history
…ht now
  • Loading branch information
iamcal authored and felixge committed Sep 2, 2010
1 parent 59dc842 commit ff65786
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test/fixture/libmysql_password.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,19 @@ void scramble_323(char *to, const char *message, const char *password)
}

int main() {
const char password[] = "root";
uint password_len = 4;
const char password1[] = "root";
const char password2[] = "long password test";
const char password3[] = "saf789yasfbsd89f";
ulong result[2];

printf("hash_password(\"%s\"):\n", password);
hash_password((ulong*)result, password1, strlen(password1));
printf("hash_password(\"%s\") = %08x%08x\n", password1, result[0], result[1]);

hash_password(result, password, password_len);
hash_password((ulong*)result, password2, strlen(password2));
printf("hash_password(\"%s\") = %08x%08x\n", password2, result[0], result[1]);

printf("result 1: %ld\n", result[0]);
printf("result 2: %ld\n", result[1]);
hash_password((ulong*)result, password3, strlen(password3));
printf("hash_password(\"%s\") = %08x%08x\n", password3, result[0], result[1]);

return 23;
}
Expand Down
13 changes: 13 additions & 0 deletions test/simple/test-auth-old.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require('../common');

var auth = require('mysql/auth');

function test_hash_password(password, bytes){
var expected = new Buffer(bytes);
var actual = auth.hashPassword(password);
assert.deepEqual(actual, expected); // , 'hashPassword('+password+') failed');
}

test_hash_password('root', [0x67, 0x45, 0x7E, 0x22, 0x6a, 0x1a, 0x15, 0xbd]);
test_hash_password('long password test', [0x6c, 0x24, 0x68, 0x41, 0x2c, 0xa6, 0x86, 0x56]);
test_hash_password('saf789yasfbsd89f', [0x6c, 0x9b, 0x2f, 0x07, 0x17, 0xeb, 0x95, 0xc6]);

0 comments on commit ff65786

Please sign in to comment.