|
|||
|
Your prog have much time to resolve this script(decryption from Base84)
if crypted file more 20 kb var cryptof = getAdditionalFile("test.swf"); f = new Folder("demo"); outputfolder = f.path; var fp = new FileStream(cryptof,"r"); var input = fp.readString(); fp.close(); function asd(input){ var keyStr = "ABCDEFGHIJKLMNOP" + "QRSTUVWXYZabcdef" + "ghijklmnopqrstuv" + "wxyz0123456789+/" + "="; var output = ""; var chr1=""; var chr2=""; var chr3 = ""; var enc1=""; var enc2=""; var enc3=""; var enc4 = ""; var i = 0; // remove all characters that are not A-Z, a-z, 0-9, +, /, or = /*var base64test = new RegExp (/[^A-Za-z0-9\+\/\=]/g); if (base64test.exec(input)){ Dialogs.msgBox("There were invalid base64 characters in the input text. Valid base64 characters are A-Z, a-z, 0-9 and Expect errors in decoding.","Alert", 0);} input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");*/ /// do { enc1 = keyStr.indexOf(input.charAt(i++)); enc2 = keyStr.indexOf(input.charAt(i++)); enc3 = keyStr.indexOf(input.charAt(i++)); enc4 = keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } chr1 = chr2 = chr3 = ""; enc1 = enc2 = enc3 = enc4 = ""; } while (i < input.length); return output; } asd(input) trace(asd(input)) trace(input) var htmlfile = outputfolder + "\\" + "test2.swf"; //var htmlfile = "test2.swf"; fp1 = new FileStream(htmlfile,"w"); uncr=asd(input); fp1.writeString(uncr); fp1.close(); Thanx alot |
|
|||
|
Please try the following
Code:
function Base64()
{
this.keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
/**
* Read a byte from the input string or file stream
*/
function readByte(input)
{
var ch = input.get();
if (input.eof) return NaN;
return ch;
}
/**
* Encode the input string or file stream, returns a stringstream
*/
function encode(input)
{
var output = new StringStream;
var chr1, chr2, chr3 ;
var enc1, enc2, enc3, enc4;
do
{
chr1 = this.readByte(input);
chr2 = this.readByte(input);
chr3 = this.readByte(input);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2))
{
enc3 = enc4 = 64;
}
else if (isNaN(chr3))
{
enc4 = 64;
}
output.write(this.keyStr.charAt(enc1) + this.keyStr.charAt(enc2) +
this.keyStr.charAt(enc3) + this.keyStr.charAt(enc4));
} while (!input.eof);
return output;
}
/**
* decode a base64 encoded string, returns a string stream
*/
function decode(input)
{
var output = new StringStream;
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
// have all characters that are not A-Z, a-z, 0-9, +, /, or =
var base64test = new RegExp("[^A-Za-z0-9+/=]", "g");
if (base64test.exec(input))
{
trace("Base64.decode: ", "invalid input string");
return null;
}
do
{
enc1 = this.keyStr.indexOf(input.charAt(i++));
enc2 = this.keyStr.indexOf(input.charAt(i++));
enc3 = this.keyStr.indexOf(input.charAt(i++));
enc4 = this.keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output.put(String.fromCharCode(chr1));
if (enc3 != 64)
{
output.put(String.fromCharCode(chr2));
}
if (enc4 != 64)
{
output.put(String.fromCharCode(chr3));
}
} while (i < input.length);
return output;
}
}
var converter = new Base64();
//var oldStream = StringStream.readFromFile("c:\\image001.JPG");
var out = converter.encode(new FileStream("c:\\image001.jpg"));//oldStream);
var str = out.toString();
//trace(str);
var newStream = converter.decode(str);
newStream.saveToFile("c:\\hello.jpg");
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|