Ideas:
Encryption: First encrypt user key A with md5 to B, then use the unique B or source file S0 to get the target file S1, and store S1 to the js variable.
When decryption: Ask for the key, and then perform the same operation as encryption.
Because md5 is used, I personally think that it cannot be cracked without a key (unless it is violent)
Run the code to view the effect:
Code example:
<Html>
<Head>
<Title> Web Encoder </title>
<Style>
Body {
Font-size: 12px;
Line-height: 12px;
Background-Color: buttonface;
Border-width: 0px;
Overflow: auto;
Margin: 0px;
Padding: 4px;
}
# T1, # t2 {
Width: 100%;
Height: 40%;
Border-width: 1px;
Overflow: auto;
Height: expression (document. body. clientHeight-100)/2 );
}
Input {
Border-width: 1px;
Padding-left: 10px;
Padding-right: 10px;
Margin: 4px;
}
</Style>
<Script>
Function webEncode (){
StrSource = escape (XOR (t1.value, STR. md5 (p1.value )));
// StrSource = t1.value;
StrOut = "<script> strHTML = "";";
For (var I = 0; I + 70 <strSource. length; I + = 70 ){
StrOut + = "strHTML + =" "+ addSlash (strSource. substring (I, I + 70) + "";";
}
StrOut + = "strHTML + =" "+ addSlash (strSource. substring (I, strSource. length) + "";";
StrOut + = XOR + "";
// Below code load the STR object
StrOut + = "var STR = {hexcase: 0,/* hex output format. 0-lowercase; 1 -";
StrOut + = "uppercase */b64pad:" ",/* base-64 pad character." = "";
StrOut + = "strict RFC compliance */chrsz: 8,/* bits per input character ";
StrOut + = ". 8-ASCII; 16-Unicode */b64_hmac_md5: function (key ,";
StrOut + = "data) {return binl2b64 (core_hmac_md5 (key, data) ;}, b64_md5 :";
StrOut + = "function (s) {return binl2b64 (core_md5 (str2binl (s), s. length * this. c ";
StrOut + = "hrsz);}, binl2b64: function (binarray) {var tab =" ABCDE ";
StrOut + = "FGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 +/"; var ";
StrOut + = "str =" "; for (var I = 0; I <binarray. length * 4; I + = 3 ){";
StrOut + = "var triplet = (binarray [I> 2]> 8 * (I % 4) & 0xFF )";
StrOut + = "<16) | (binarray [I + 1> 2]> 8 * (I + 1) % 4 ))&";
StrOut + = "0xFF) <8) | (binarray [I + 2> 2]> 8 * (I + 2) % ";
StrOut + = "4) & 0xFF); for (var j = 0; j <4; j ++) {if (I ";
StrOut + = "* 8 + j * 6> binarray. length * 32) str + = this. b64pad; else ";
StrOut + = "str + = tab. charAt (triplet> 6 * (3-j) & 0x3F) ;}} r ";
StrOut + = "eturn str;}, binl2hex: function (binarray) {var hex_t ";
StrOut + = "AB = this. hexcase? "0123456789 ABCDEF": "0123456789 abcdef"; var ";
StrOut + = "str =" "; for (var I = 0; I <binarray. length * 4; I ++ ){";
StrOut + = "str + = hex_tab.charAt (binarray [I> 2]> (I % 4) * 8 + 4) & 0xF) + ";
StrOut + = "hex_tab.charAt (binarray [I> 2] >>( (I % 4) * 8) & 0xF );";
StrOut + = "} return str;}, binl2str: function (bin) {var st ";
StrOut + = "r =" "; var mask = (1 <this. chrsz)-1; for (var I = 0; I <";
StrOut + = "bin. length * 32; I + = this. chrsz) str + = String. fromCharCode ((";
StrOut + = "bin [I> 5] >>> (I % 32) & mask); return str ;}, bit_rol :";
StrOut + = "function (num, cnt) {return (num <cnt) | (num >>> (32-cnt ));},";
StrOut + = "core_hmac_md5: function (key, data) {var bkey = str2binl (k ";
StrOut + = "ey); if (bkey. length> 16) bkey = core_md5 (bkey, key. length * this ";
StrOut + = ". chrsz); var ipad = Array (16), opad = Array (16); for (var ";
StrOut + = "I = 0; I <16; I ++) {ipad = bkey ^ 0x36363636 ;";
StrOut + = "opad = bkey ^ 0x5C5C5C5C;} var hash = core_md ";
StrOut + = "5 (ipad. concat (str2binl (data), 512 + data. length * this. chrsz); r ";
StrOut + = "eturn core_md5 (opad. concat (hash), 512 + 128) ;}, core_md5 :";
StrOut + = "function (x, len) {/* append padding */x [len> 5] | = 0x80 ";
StrOut + = "<(len) % 32); x [(len + 64)> 9) <4) + 14] = len ;";
StrOut + = "var a = 1732584193; var B =-271733879; var c =-17325841 ";
StrOut + = "94; var d = 271733878; for (var I = 0; I <x. length; I + ";
StrOut + = "= 16) {var olda = a; var oldb = B; var oldc ";
StrOut + = "= c; var oldd = d; a = this. md5_ff (a, B, c, d, x [I + ";
StrOut + = "0], 7,-680876936); d = this. md5_ff (d, a, B, c, x [I + 1], 12 ,";
StrOut + = "-389564586); c = this. md5_ff (c, d, a, B, x [I + 2], 17,606 10581 ";
StrOut + = "9); B = this. md5_ff (B, c, d, a, x [I + 3], 22,-1044525330 );";
StrOut + = "a = this. md5_ff (a, B, c, d, x [I + 4], 7,-176418897); d = th ";
StrOut + = "is. md5_ff (d, a, B, c, x [I + 5], 12,120 0080426); c = this. md5_f ";
StrOut + = "f (c, d, a, B, x [I + 6], 17,- 1473231341); B = this. md5_ff (B, c ,";
StrOut + = "d, a, x [I + 7], 22,-45705983); a = this. md5_ff (a, B, c, d, x [I + ";
StrOut + = "8], 7, 1770035416); d = this. md5_ff (d, a, B, c, x [I + 9], 12 ,";
StrOut + = "-1958414417); c = this. md5_ff (c, d, a, B, x [I + 10], 17,-42063 )";
StrOut + = "; B = this. md5_ff (B, c, d, a, x [I + 11], 22,-1990404162 );";
StrOut + = "a = this. md5_ff (a, B, c, d, x [I + 12], 7, 1804603682); d = thi ";
StrOut + = "s. md5_ff (d, a, B, c, x [I + 13], 12,-40341101); c = this. md5_ff (c ";
StrOut + = ", d, a, B, x [I + 14], 17,- 1502002290); B = this. md5_ff (B, c, d ,";
StrOut + = "a, x [I + 15], 22,123 6521329); a = this. md5_gg (a, B, c, d, x ";
StrOut + = "[I + 1], 5,-165796510); d = this. md5_gg (d, a, B, c, x [I + 6], 9 ";
StrOut + = ",-1069501632); c = this. md5_gg (c, d, a, B, x [I + 11], 14,643 7 ";
StrOut + = "17713); B = this. md5_gg (B, c, d, a, x [I + 0], 20,-373897302 );";
StrOut + = "a = this. md5_gg (a, B, c, d, x [I + 5], 5,-701558691); d = ";
StrOut + = "this. md5_gg (d, a, B, c, x [I + 10], 9, 38016083); c = this. md5 _";
StrOut + = "gg (c, d, a, B, x [I + 15], 14,- 660478335); B = this. md5_gg (B, c ,";
StrOut + = "d, a, x [I + 4], 20,-405537848); a = this. md5_g