I would think the built-in ByteArray.compress would be much faster than 5-10
seconds for a simple 100k string. But if it doesn't work, a really simple
method of "encrypting" a string is doing a bit-flip on each character ...

// your original string (try this out with large files)
var str:String = "123456789";
var newStr:String = "";

// some random number between 0 and 255
var bitFlip:uint = 76;
for(var i:uint = 0; i < str.length; i++)
{
    // using the bitFlip value do an XOR on the character
    newStr += String.fromCharCode( str.charCodeAt(i) ^ bitFlip );
}
// new string is un-readable
trace(newStr);
// to translate back to the original string, simply flip
// the character back using the same bitFlip value
str = "";
for(i = 0; i < newStr.length; i++)
{
    str += String.fromCharCode( newStr.charCodeAt(i) ^ bitFlip );
}
// once again you have the original
trace(str);


Even if it's not real security, it's always a heap of fun. Good luck!

Tyler


On 8/16/07, Mick G <[EMAIL PROTECTED]> wrote:
>
> I've tried different compressions classes - they're just too slow (even
> with
> some I tried that throw "chunks" of data at the class in intervals, it
> still
> took 5 - 10 seconds.
>
> And yes the purpose is to make it unreadable.
>
> I've written a very simple function that replaces the numbers 1 - 20 with
> custom characters using split.join. It performs this in 170 milliseconds
> to
> encrypt (and takes about 10% off the file size since in some instances I'm
> replacing 2 characters with 1).
>
> I guess using split and join is much faster than I thought.
>
>
>
> On 8/16/07, elibol <[EMAIL PROTECTED]> wrote:
> >
> > Why do you need to encrypt it? If you just need it unreadable, then why
> > not
> > kill two birds with one stone and compress it?
> >
> >
> >
> http://www.razorberry.com/blog/archives/2004/08/22/lzw-compression-methods-in-as2/
> >
> > On 8/16/07, Mick G <[EMAIL PROTECTED]> wrote:
> > >
> > > I need a way to encrypt a LARGE string (up to 100k of text) - my data
> is
> > > mostly xy coordinates so 90% numbers.
> > >
> > > I've tried a few AS encryption classes that I've found online and
> > > considering I have such a large string, they're all too slow. It
> doesn't
> > > need to be too secure - decryption speed is more import than security.
> > >
> > > I was thinking of just doing a simple custom character replace with
> > > split.join replacing each numeral 0-9 with a character, but does
> anyone
> > > have
> > > any other ideas on a efficient/fast way of doing this?
> > >
> > > - Mick
> > > _______________________________________________
> > > Flashcoders@chattyfig.figleaf.com
> > > To change your subscription options or search the archive:
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > > Brought to you by Fig Leaf Software
> > > Premier Authorized Adobe Consulting and Training
> > > http://www.figleaf.com
> > > http://training.figleaf.com
> > >
> > _______________________________________________
> > Flashcoders@chattyfig.figleaf.com
> > To change your subscription options or search the archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
> >
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to