1 |
|
2 | var crypto = require('crypto');
|
3 |
|
4 | var salt = 'wherestheninja';
|
5 |
|
6 | exports.setSeed = function(seed)
|
7 | {
|
8 | salt = seed;
|
9 | };
|
10 |
|
11 | exports.gen_salt_sync = function(num)
|
12 | {
|
13 | return salt;
|
14 | };
|
15 |
|
16 | var encrypt_sync = exports.encrypt_sync = function(password)
|
17 | {
|
18 |
|
19 | return password ? crypto.createHmac('sha1', salt).update(password).digest('hex') : password;
|
20 | };
|
21 |
|
22 | var compare_sync = exports.compare_sync = function(raw,hashed)
|
23 | {
|
24 | return (!hashed && !raw) || hashed == encrypt_sync(raw);
|
25 | }; |
\ | No newline at end of file |