Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 67 lines (49 sloc) 1.932 kb
9371132 @brainfucker nothing
authored
1 # Hashlib
c68614b @brainfucker update readme
authored
2 *Is a FAST nodejs(http://github.com/ry/node/) library for making hashes written in C/C++*
13ed3d8 @brainfucker update readme
authored
3
e48aafa @brainfucker hmac_md5 help
authored
4 *Supports: md4, md5, md6, sha, sha1, sha256, sha512, hmac_sha1, hmac_md5*, also can make md5 hash of files
9371132 @brainfucker nothing
authored
5
6268276 @brainfucker update readme
authored
6 *Thangs to Vanilla Hsu for speed improvements and md4, sha support*
3980178 @brainfucker update readme
authored
7
9371132 @brainfucker nothing
authored
8 ## Install:
d823c51 @brainfucker Add makefile, update readme
authored
9 ### way 1
ae09bef @brainfucker update readme
authored
10 1) go to the directory with hashlib library
ca32bc3 @brainfucker update readme
authored
11
d823c51 @brainfucker Add makefile, update readme
authored
12 2) execute `node-waf configure build`
ca32bc3 @brainfucker update readme
authored
13
d823c51 @brainfucker Add makefile, update readme
authored
14 3) get module from `./build/default/hashlib.node`
15
13ed3d8 @brainfucker update readme
authored
16 You should use `var hashlib = require("./build/default/hashlib");` (way to module)
d823c51 @brainfucker Add makefile, update readme
authored
17
523e8b4 @brainfucker update readme
authored
18 ### way 2 (works if node are installed in default path)
75298c3 @brainfucker update readme
authored
19 1) go to the directory with hashlib library
ca32bc3 @brainfucker update readme
authored
20
d823c51 @brainfucker Add makefile, update readme
authored
21 2) execute `make`
ca32bc3 @brainfucker update readme
authored
22
13ed3d8 @brainfucker update readme
authored
23 3) execute `sudo make install`
d823c51 @brainfucker Add makefile, update readme
authored
24
13ed3d8 @brainfucker update readme
authored
25 You should use `var hashlib = require("hashlib");` (from any path)
d823c51 @brainfucker Add makefile, update readme
authored
26
9371132 @brainfucker nothing
authored
27 ## Functions:
528af7f @brainfucker Update README.md
authored
28 md4(str); // Returns md4 hash from string
29 md5(str); // Returns md5 hash from string
30 sha(str); // Returns sha hash from string
31 sha1(str); // Returns sha1 hash from string
32 sha256(str); // Returns sha256 hash from string
33 sha512(str); // Returns sha512 hash from string
34 md6(str[, length]); // Returns md6 hash from string, second parametr is optional
be070af @brainfucker add async callback to md5_file function
authored
35 md5_file(path[, callback]); // Returns md5 hash from file callback is optional and works async
e48aafa @brainfucker hmac_md5 help
authored
36 hmac_sha1(str, key) // Returns hmac sha1 hash with an key
37 hmac_md5(str, key) // Returns hmac md5 hash with an key
9371132 @brainfucker nothing
authored
38
d823c51 @brainfucker Add makefile, update readme
authored
39 ## Usage:
ca32bc3 @brainfucker update readme
authored
40 var hashlib = require('hashlib');
9371132 @brainfucker nothing
authored
41 hashlib.md5('text');
d823c51 @brainfucker Add makefile, update readme
authored
42
43 ## Speed testing
44 To run speed test on your computer run test.js, here is my:
45 C++ md5 result is: 220
46 JS md5 result is: 5660
47 C++ module faster than JS in 25.727272727272727 times
48 -----------
49 C++ md4 result is: 212
50 C++ md6 result is: 3889
51 C++ sha0 result is: 228
52 C++ sha1 result is: 495
53 C++ sha256 result is: 712
54 C++ sha512 result is: 612
55
56 // Smaller is better
57
58 Other modules, engines md5 comparsion:
59 hashlib: 220
60 node-crypto: 1055
61 python-hashlib: 265
62 php: 179
63
64 // Smaller is better
e6d96cc @brainfucker update readme
authored
65
66 <img src="http://nodejs.ru/img/small.png">
Something went wrong with that request. Please try again.