Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit c6a0d2c12b978ce7466ab643732288b153ca966e @waveto committed Nov 22, 2009
Showing with 797 additions and 0 deletions.
  1. +18 −0 LICENSE
  2. +35 −0 README
  3. +644 −0 crypto.cc
  4. +30 −0 test.js
  5. +20 −0 test_cert.pem
  6. +15 −0 test_key.pem
  7. +35 −0 wscript
18 LICENSE
@@ -0,0 +1,18 @@
+// Copyright 2009, Acknack Ltd. All rights reserved.
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
35 README
@@ -0,0 +1,35 @@
+node-crypto
+===========
+
+A wrapper around openssl for node.js, currently exposing Hashing, Signing
+and Verifying methods.
+
+To install, ensure that you have openssl installed, and run:
+
+node-waf configure
+node-waf build
+
+This will put the crypto.node binary module in build/default.
+
+The hashing, signing and verifying methods can work with binary, hex or
+base64 encoded strings.
+
+Quick example
+-------------
+
+var sys=require("sys");
+var posix=require('posix');
+var crypto=require("./crypto");
+
+// Test hashing
+var h1 = (new crypto.Hash).init("sha1").update("Test123").digest("hex");
+var h2 = (new crypto.Hash).init("sha1").update("Test").update("123").digest("hex");
+sys.puts(h1===h2);
+
+// Load our public and private keys
+var keyPem = posix.cat("test_key.pem").wait();
+var certPem = posix.cat("test_cert.pem").wait();
+
+// Test signing and verifying
+var s1 = (new crypto.Sign).init("RSA-SHA256").update("Test123").sign(keyPem, "base64");
+sys.puts((new crypto.Verify).init("RSA-SHA256").update("Test").update("123").verify(certPem, s1, "base64"));
Oops, something went wrong.

0 comments on commit c6a0d2c

Please sign in to comment.