Permalink
Browse files

Added hashlib.

  • Loading branch information...
1 parent 6682b6c commit 9a4919ffc63436718b7167f6b37ae06c82a0cb72 Jonas Galvez committed Aug 31, 2010
Showing with 10,799 additions and 0 deletions.
  1. +2 −0 lib/hashlib/.gitignore
  2. +66 −0 lib/hashlib/README.md
  3. +435 −0 lib/hashlib/hashlib.cc
  4. +524 −0 lib/hashlib/lib/md5/_hashopenssl.c
  5. +381 −0 lib/hashlib/lib/md5/md5.c
  6. +91 −0 lib/hashlib/lib/md5/md5.h
  7. +312 −0 lib/hashlib/lib/md5/md5module.c
  8. +16 −0 lib/hashlib/lib/md6/README_Reference.txt
  9. +305 −0 lib/hashlib/lib/md6/inttypes.h
  10. +443 −0 lib/hashlib/lib/md6/md6.h
  11. +444 −0 lib/hashlib/lib/md6/md6_compress.c
  12. +881 −0 lib/hashlib/lib/md6/md6_mode.c
  13. +96 −0 lib/hashlib/lib/md6/md6_nist.c
  14. +86 −0 lib/hashlib/lib/md6/md6_nist.h
  15. +785 −0 lib/hashlib/lib/md6/md6sum.c
  16. +222 −0 lib/hashlib/lib/md6/stdint.h
  17. +274 −0 lib/hashlib/lib/sha/SHA1.cpp
  18. +148 −0 lib/hashlib/lib/sha/SHA1.h
  19. +367 −0 lib/hashlib/lib/sha/sha256module.c
  20. +456 −0 lib/hashlib/lib/sha/sha512module.c
  21. +327 −0 lib/hashlib/lib/sha/shamodule.c
  22. +43 −0 lib/hashlib/libhash/md4.h
  23. +289 −0 lib/hashlib/libhash/md4c.c
  24. +49 −0 lib/hashlib/libhash/md5.h
  25. +320 −0 lib/hashlib/libhash/md5c.c
  26. +87 −0 lib/hashlib/libhash/ripemd.h
  27. +544 −0 lib/hashlib/libhash/rmd160c.c
  28. +216 −0 lib/hashlib/libhash/rmd_locl.h
  29. +399 −0 lib/hashlib/libhash/rmdconst.h
  30. +87 −0 lib/hashlib/libhash/sha.h
  31. +450 −0 lib/hashlib/libhash/sha0c.c
  32. +490 −0 lib/hashlib/libhash/sha1c.c
  33. +44 −0 lib/hashlib/libhash/sha256.h
  34. +296 −0 lib/hashlib/libhash/sha256c.c
  35. +243 −0 lib/hashlib/libhash/sha_locl.h
  36. +8 −0 lib/hashlib/makefile
  37. +2 −0 lib/hashlib/test.file
  38. +136 −0 lib/hashlib/test.js
  39. +13 −0 lib/hashlib/test.php
  40. +11 −0 lib/hashlib/test.py
  41. +381 −0 lib/hashlib/test/md5.js
  42. +30 −0 lib/hashlib/wscript
View
@@ -0,0 +1,2 @@
+build
+.lock-wscript
View
@@ -0,0 +1,66 @@
+# Hashlib
+*Is a FAST nodejs(http://github.com/ry/node/) library for making hashes written in C/C++*
+
+*Supports: md4, md5, md6, sha, sha1, sha256, sha512, hmac_sha1, hmac_md5*, also can make md5 hash of files
+
+*Thangs to Vanilla Hsu for speed improvements and md4, sha support*
+
+## Install:
+### way 1
+1) go to the directory with hashlib library
+
+2) execute `node-waf configure build`
+
+3) get module from `./build/default/hashlib.node`
+
+You should use `var hashlib = require("./build/default/hashlib");` (way to module)
+
+### way 2 (works if node are installed in default path)
+1) go to the directory with hashlib library
+
+2) execute `make`
+
+3) execute `sudo make install`
+
+You should use `var hashlib = require("hashlib");` (from any path)
+
+## Functions:
+ md4(str); // Returns md4 hash from sting
+ md5(str); // Returns md5 hash from sting
+ sha(str); // Returns sha hash from sting
+ sha1(str); // Returns sha1 hash from sting
+ sha256(str); // Returns sha256 hash from sting
+ sha512(str); // Returns sha512 hash from sting
+ md6(str[, length]); // Returns md6 hash from sting, second parametr is optional
+ md5_file(path[, callback]); // Returns md5 hash from file callback is optional and works async
+ hmac_sha1(str, key) // Returns hmac sha1 hash with an key
+ hmac_md5(str, key) // Returns hmac md5 hash with an key
+
+## Usage:
+ var hashlib = require('hashlib');
+ hashlib.md5('text');
+
+## Speed testing
+To run speed test on your computer run test.js, here is my:
+ C++ md5 result is: 220
+ JS md5 result is: 5660
+ C++ module faster than JS in 25.727272727272727 times
+ -----------
+ C++ md4 result is: 212
+ C++ md6 result is: 3889
+ C++ sha0 result is: 228
+ C++ sha1 result is: 495
+ C++ sha256 result is: 712
+ C++ sha512 result is: 612
+
+ // Smaller is better
+
+Other modules, engines md5 comparsion:
+ hashlib: 220
+ node-crypto: 1055
+ python-hashlib: 265
+ php: 179
+
+ // Smaller is better
+
+<img src="http://nodejs.ru/img/small.png">
Oops, something went wrong.

0 comments on commit 9a4919f

Please sign in to comment.