UNPKG

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