2150 |
mathias |
1 |
if(!dojo._hasResource["dojox.crypto.tests.Blowfish"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
|
|
2 |
dojo._hasResource["dojox.crypto.tests.Blowfish"] = true;
|
|
|
3 |
dojo.provide("dojox.crypto.tests.Blowfish");
|
|
|
4 |
dojo.require("dojox.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.crypto;
|
|
|
11 |
|
|
|
12 |
tests.register("dojox.crypto.tests.Blowfish", [
|
|
|
13 |
function testEncrypt(t){
|
|
|
14 |
t.assertEqual(base64Encrypted, dxc.Blowfish.encrypt(message, key));
|
|
|
15 |
},
|
|
|
16 |
function testDecrypt(t){
|
|
|
17 |
t.assertEqual(message, dxc.Blowfish.decrypt(base64Encrypted, key));
|
|
|
18 |
},
|
|
|
19 |
function testShortMessage(t){
|
|
|
20 |
var msg="pass";
|
|
|
21 |
var pwd="foobar";
|
|
|
22 |
var enc=dxc.Blowfish.encrypt(msg, pwd);
|
|
|
23 |
var dec=dxc.Blowfish.decrypt(enc, pwd);
|
|
|
24 |
t.assertEqual(dec, msg);
|
|
|
25 |
}
|
|
|
26 |
]);
|
|
|
27 |
})();
|
|
|
28 |
|
|
|
29 |
}
|