]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojox/encoding/tests/crypto/Blowfish.js
add Dojo 1.1.1
[eow] / static / dojo-release-1.1.1 / dojox / encoding / tests / crypto / Blowfish.js
1 if(!dojo._hasResource["dojox.encoding.tests.crypto.Blowfish"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.encoding.tests.crypto.Blowfish"] = true;
3 dojo.provide("dojox.encoding.tests.crypto.Blowfish");
4 dojo.require("dojox.encoding.crypto.Blowfish");
5
6 (function(){
7         var message="The rain in Spain falls mainly on the plain.";
8         var key="foobar";
9         var base64Encrypted="WI5J5BPPVBuiTniVcl7KlIyNMmCosmKTU6a/ueyQuoUXyC5dERzwwdzfFsiU4vBw";
10         var dxc=dojox.encoding.crypto;
11
12         tests.register("dojox.encoding.crypto.tests.Blowfish", [
13                 function testEncrypt(t){
14                         var dt=new Date();
15                         t.assertEqual(base64Encrypted, dxc.Blowfish.encrypt(message, key));
16                         doh.debug("testEncrypt: ", new Date()-dt, "ms.");
17                 },
18                 function testDecrypt(t){
19                         var dt=new Date();
20                         t.assertEqual(message, dxc.Blowfish.decrypt(base64Encrypted, key));
21                         doh.debug("testDecrypt: ", new Date()-dt, "ms.");
22                 },
23                 function testShortMessage(t){
24                         var msg="pass";
25                         var pwd="foobar";
26                         var dt=new Date();
27                         var enc=dxc.Blowfish.encrypt(msg, pwd);
28                         var dec=dxc.Blowfish.decrypt(enc, pwd);
29                         t.assertEqual(dec, msg);
30                         doh.debug("testShortMessage: ", new Date()-dt, "ms.");
31                 }
32         ]);
33 })();
34
35 }