forked from phpmycoder/cryptico-node
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathhash.js
More file actions
48 lines (40 loc) · 737 Bytes
/
hash.js
File metadata and controls
48 lines (40 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
*
* Secure Hash Algorithm (SHA256)
* http://www.webtoolkit.info/
*
* Original code by Angel Marin, Paul Johnston.
*
**/
var crypto = require('crypto');
function SHA256(s){
return crypto.createHash('sha256').update(s, 'utf8').digest('hex');
}
var sha256 = {}
sha256.hex = function(s)
{
return SHA256(s);
}
/**
*
* Secure Hash Algorithm (SHA1)
* http://www.webtoolkit.info/
*
**/
function SHA1 (msg) {
return crypto.createHash('sha1').update(msg, 'utf8').digest('hex');
}
var sha1 = {}
sha1.hex = function(s)
{
return SHA1(s);
}
/**
*
* MD5 (Message-Digest Algorithm)
* http://www.webtoolkit.info/
*
**/
var MD5 = function (string) {
return crypto.createHash('md5').update(string, 'utf8').digest('hex');
}