Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/isaacs/node-crypto
Browse files Browse the repository at this point in the history
Conflicts:
	test.js
  • Loading branch information
greut committed Mar 24, 2010
2 parents ae8d97c + dc9c38d commit c87f06c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
.lock-wscript
build/
crypto.node
28 changes: 1 addition & 27 deletions README
Expand Up @@ -19,30 +19,4 @@ base64 encoded strings.
The encrypt / decrypt methods work with binary, hex or base64 encodings, The encrypt / decrypt methods work with binary, hex or base64 encodings,
with streaming. with streaming.


Quick example See test.js for example usage.
-------------

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"));

// Test encryption and decryption
var plaintext="Keep this a secret? No! Tell everyone about node.js!";

var cipher=(new crypto.Cipher).init("aes192", "MySecretKey123");
var ciph=cipher.update(plaintext, 'utf8', 'hex');
ciph+=cipher.final('hex');
sys.puts(ciph);
11 changes: 11 additions & 0 deletions package.json
@@ -0,0 +1,11 @@
{ "name" : "crypto"
, "author" : "Rhys <rhys@wave.to>"
, "version" : "1.0.0"
, "scripts" :
{ "preinstall" : "node-waf configure"
, "install" : "node-waf build"
, "test" : "node test.js"
}
, "main" : "build/default/crypto"
, "engines" : [ "node" ]
}

0 comments on commit c87f06c

Please sign in to comment.