From 0ed3532699fb67c5054c7732c2ab2371abdf3eb0 Mon Sep 17 00:00:00 2001 From: Benjamin Fritsch Date: Mon, 19 Jul 2010 08:04:22 +0200 Subject: [PATCH] added test for Issue #214 --- test/fixtures/sample.png | Bin 0 -> 9416 bytes test/simple/test-crypto.js | 11 +++++++++++ 2 files changed, 11 insertions(+) create mode 100644 test/fixtures/sample.png diff --git a/test/fixtures/sample.png b/test/fixtures/sample.png new file mode 100644 index 0000000000000000000000000000000000000000..258622019038678b7c3abd376dfeedd62fe99f14 GIT binary patch literal 9416 zcmbW6byO6<_vjavknTT$%-zmM#GS1?g_-UXWTs8kX*o-lbg0 z$M^Sp=e={@U+=v;@z30uGoLea=g!Q1n15IYkiJz`QwCsQ000<|3Gi?akXF=Ddi5Tp zBgJa>k(XASUL2@}poqX6z@}*jQND__(+@PYCe|2?_8C2#AQuNr{NbhzSTtsY%HwD5 z!14%*jqzUs_@9D-`8Y=$+$VVW1dj@hqyS6|AP^G^_@7xnY6m>F1F*=j$)5_o!lBT% z!ew)#6bebod&2&@_7|1TB$7k;gL^0*J~a(39sM&-F7D?qL`22JB_yR3-zX`osH(ly zeXpl)U}$7){n5tO?vuTPho_gf55(6m>~nZTWK?uaa?01#wDfP^Gx7@xi;7E1%gXEO z8ycIMTUy(Cdi(kZ;DbZMQ`0lEh`ITN#f{Ca?Va7dKl=x$v-69~tH0=f*Z<+d0093R z>#_cCu>XUL?2!u-3k!&a`yVb0OrOUBB*VgfDu_e=N*mY8je<=mw<}NFb?!&c!V4r>kC%_*QqC@lkbz~4QtXRM^-XbSg-Ng}`Z;e6p)E#CAuSc! zJ*sH2uMYqcFOwi_hv{L@{0L2;`InR(!ND8pT3O=hTho8v;MG!))xW*j0zt&fhCB|} zKjf{%-Y${5Z#fLoupA6PwgBQ(b0a629%hC|_gs!Dn^^ah$m4>e8RJv0{+=HV7&;oH zemLx4Q{)Oy^X%p4IT)2`-{ceUQ=3MAul2(2YQU{(4QnK*9c{IlMWH!ES2SDwvT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9P^GurutuTMNO;$fmiUKwFFW0NyqQvNwnF z^-8>wF=a6xK!-WO$kADj%-@Wk6xAo+jEoN_muXNj!BDq{h6`dbF#T(%j9B1`&ZDmxaqMaoC$2 zfhNtWP^K-j?-obL4$F({4}kKOE7xv6Or|!!j1rXM`d-9k4b_O>q^Xgbh{M^lxB*IA V$!9S&9?O68iny#6$KVeO{{!3ra})po literal 0 HcmV?d00001 diff --git a/test/simple/test-crypto.js b/test/simple/test-crypto.js index 0510c93d7f..d95a6c0e30 100644 --- a/test/simple/test-crypto.js +++ b/test/simple/test-crypto.js @@ -10,6 +10,7 @@ try { var fs = require('fs'); var sys = require('sys'); +var path = require('path'); // Test Certificates var caPem = fs.readFileSync(common.fixturesDir+"/test_ca.pem", 'ascii'); @@ -39,6 +40,16 @@ var h1 = crypto.createHash("sha1").update("Test123").digest("hex"); var h2 = crypto.createHash("sha1").update("Test").update("123").digest("hex"); assert.equal(h1, h2, "multipled updates"); +// Test hashing for binary files +fn = path.join(common.fixturesDir, 'sample.png'); +var sha1Hash = crypto.createHash('sha1'); +var fileStream = fs.createReadStream(fn); +fileStream.addListener('data', function(data){ + sha1Hash.update(data); +}); +fileStream.addListener('close', function(){ + assert.equal(sha1Hash.digest('hex'), '22723e553129a336ad96e10f6aecdf0f45e4149e', 'Test SHA1 of sample.png'); +}); // Test signing and verifying var s1 = crypto.createSign("RSA-SHA1").update("Test123").sign(keyPem, "base64");