Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-07-2005, 04:39 AM
Junior Member
 
Join Date: Oct 2005
Posts: 2
Default Lack of memory

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
Reply With Quote
  #2 (permalink)  
Old 10-07-2005, 01:13 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Lack of memory

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");
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 02:00 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.