95146d2eb7abb127db5e4b8386e332e2bb83e7ac.svn-base 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. if (!dojo._hasResource["dojox.crypto.tests.Blowfish"]) { // _hasResource
  2. // checks added by
  3. // build. Do not use
  4. // _hasResource
  5. // directly in your
  6. // code.
  7. dojo._hasResource["dojox.crypto.tests.Blowfish"] = true;
  8. dojo.provide("dojox.crypto.tests.Blowfish");
  9. dojo.require("dojox.crypto.Blowfish");
  10. (function() {
  11. var message = "The rain in Spain falls mainly on the plain.";
  12. var key = "foobar";
  13. var base64Encrypted = "WI5J5BPPVBuiTniVcl7KlIyNMmCosmKTU6a/ueyQuoUXyC5dERzwwdzfFsiU4vBw";
  14. var dxc = dojox.crypto;
  15. tests.register("dojox.crypto.tests.Blowfish", [function testEncrypt(t) {
  16. t.assertEqual(base64Encrypted, dxc.Blowfish.encrypt(
  17. message, key));
  18. }, function testDecrypt(t) {
  19. t.assertEqual(message, dxc.Blowfish.decrypt(
  20. base64Encrypted, key));
  21. }, function testShortMessage(t) {
  22. var msg = "pass";
  23. var pwd = "foobar";
  24. var enc = dxc.Blowfish.encrypt(msg, pwd);
  25. var dec = dxc.Blowfish.decrypt(enc, pwd);
  26. t.assertEqual(dec, msg);
  27. }]);
  28. })();
  29. }