Created
November 30, 2010 04:56
-
-
Save supahgreg/721174 to your computer and use it in GitHub Desktop.
testing GM_cryptoHash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @id cryptoHashTests@phob.net | |
| // @name Crypto Hash Tests | |
| // @namespace phob.net | |
| // @description testing GM_cryptoHash | |
| // @include http://phob.net/* | |
| // @include http://*.phob.net/* | |
| // ==/UserScript== | |
| /* case 1: no arguments */ | |
| GM_log("this will throw a toString() error: " + GM_cryptoHash()); | |
| /* case 2: null passed */ | |
| //GM_log("this will throw a toString() error: " + GM_cryptoHash(null)); | |
| /* case 3: object passed */ | |
| //GM_log("SHA1 / UTF-8(def) hash of an object:\n" | |
| // + "expect: 5ffe533b830f08a0326348a9160afafc8ada44db\n" | |
| // + "result: " + GM_cryptoHash(new Object(true))); | |
| /* case 4: string passed, valid algorithm passed */ | |
| //GM_log("MD5 / UTF-8(def) hash of the string 'yay':\n" | |
| // + "expect: 402acb1c3e3f37da6e1bb6cacadc315d\n" | |
| // + "result: " + GM_cryptoHash("yay", "md5")); | |
| /* case 5: string passed, INVALID algorithm passed */ | |
| //GM_log("this will throw an 'invalid hash algorithm' error: " | |
| // + GM_cryptoHash("yay", "md555")); | |
| /* case 6: string passed, algorithm=null, valid charset passed */ | |
| //GM_log("SHA1(def) / UTF-16 hash of the string 'yay':\n" | |
| // + "expect: 2806d14df71f642cc0ae137971930e930ac10151\n" | |
| // + "result: " + GM_cryptoHash("yay", null, "UTF-16")); | |
| /* case 7: string passed, algorithm passed, INVALID charset passed */ | |
| //GM_log("this will throw an 'invalid charset' error: " | |
| // + GM_cryptoHash("yay", "sha256", "YAY-1")); | |
| /* case 8: string passed, algorithm passed, INVALID "UTF"-like charset passed */ | |
| //GM_log("this will throw an 'invalid charset' error: " | |
| // + GM_cryptoHash("yay", "sha1", "UTF-999")); | |
| /* case 9: string passed, algorithm passed, charset passed */ | |
| //GM_log("SHA256 / UTF-8 hash of the string 'yay':\n" | |
| // + "expect: f6078ebe0c2f08c225c0349aef2fe062d71b972e3c91b9687cccdff24d0c8ac8\n" | |
| // + "result: " + GM_cryptoHash("yay", "sHa256", "UTf-8")); | |
| /* case 10: whitespace: string passed, algorithm passed, valid charset passed */ | |
| //GM_log("SHA256 / UTF-8 hash of the string 'yay':\n" | |
| // + "expect: f6078ebe0c2f08c225c0349aef2fe062d71b972e3c91b9687cccdff24d0c8ac8\n" | |
| // + "result: " + GM_cryptoHash("yay", " sHa256 ", " UTf-8")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment