Small tutorial on encryption
Results 1 to 3 of 3

Thread: Small tutorial on encryption

  1. #1
    Junior Member
    Join Date
    Sep 2002
    Posts
    28

    Small tutorial on encryption

    I do not have much time, so I'll do the best i can with the time i have.
    Encryption can be simple, and even those encryptions are enough to "kick-off" 99.9% people that are up to "crack" into your data. For example, simple encryption can be converting all characters to ascii numbers, and possibly reverse them. For example:
    Code:
    variable = "I'm the king of the world!";
    tmp = "";
    for (i=1;i<=length(variable);i++) {
    tmp += ord(substring(variable,i,1));
    }
    variable = tmp;
    this will result in turning variable to:
    Code:
    339109321161041013210710511010332111102321161041013211911111410810033
    Not quite nice, right? But there is one little problem, since some chars can be 2 and some 3 numbers in length (some one), it would be pretty hard to extract them back, so, let's change the script to:
    Code:
    variable = "I'm the king of the world!";
    tmp = "";
    for (i=1;i<=length(variable);i++) {
    tmp2 = ord(substring(variable,i,1));
    while (length(tmp2) < 3) {
    tmp2 = "0" + tmp2;
    }
    tmp += tmp2;
    }
    variable = tmp;
    Now we got:
    Code:
    073039109032116104101032107105110103032111102032116104101032119111114108100033
    Now it's better, isn't it? OK, so let's twist it even more by reversing it:
    Code:
    tmp = ""
    for(i=length(variable);i>0;i--) {
    tmp = substring(variable,i,1) + tmp;
    }
    variable = tmp;
    So we have:
    Code:
    330001801411111911230101401611230201111230301011501701230101401611230901930370
    Let's complicate it even more... let's add 2 random numbers after each 4 of this string:
    Code:
    tmp = ""
    for(i=1;i<=length(variable);i+=4) {
    tmp = substring(variable,i,4) + random(9) + random(9);
    }
    variable = tmp;
    Now we have:
    Code:
    3300550180411411041119211123330101204016821123570201341112053030321011825017250123510101224016041123
    180901349303607013
    which looks quite impossible to crack if you don't know the exact algorythm for this... now, lets complicate it even more, by reversing this string:
    Code:
    tmp = ""
    for(i=length(variable);i>0;i--) {
    tmp = substring(variable,i,1) + tmp;
    }
    variable = tmp;
    Viola, and we have:
    Code:
    3300460180631411211119581123150101524016671123850201641112143030761011815017530123430101164016601123530901779303107057
    Interesting? Those are basic numbers/strings manipulations which looks like impossible to crack. Now let's add locking/unlocking key. For example:
    Code:
    tmp = ""
    key = "locked";
    // first we will convert it to numbers, because we are talking about pure numeric encryption now
    for (i=1;i<=length(key);i++) {
    tmp2 = ord(substring(key,i,1));
    while (length(tmp2) < 3) {
    tmp2 = "0" + tmp2;
    }
    tmp += tmp2;
    }
    key = tmp;
    and let's now apply it to our "encrypted" data, by pattern, 1 number of the key will be added to first 3 numbers, second will be added to second 3 numbers, etc.
    Code:
    tmp = "";
    cnt = 1;
    for(i=1;i<=length(variable);i+=3) {
    tmp += substring(variable,i,3).valueOf() + substring(key,cnt,3).valueOf();
    cnt += 3;
    if (cnt == length(key)) {
    cnt = 1;
       }
    }
    variable = tmp;
    Now we have:
    Code:
    3301080871110180990211071411011661001119401123760101634016671123200201631112573030461011625017570123740101184016851123850901739303757038
    This is almost the maximum that you can do with numbers encryption manipulation... you can of course now play with it more to make it more complicated, but i'll leave that to you.

    To get it back, you'll use RE (reverse engineering)... I wont write the script, but it's easy to figure it out... you will just same things, but backwards... you'll first "remove" key (each 3 numbers - current number of key), then you'll reverse it... then you'll remove those random 2 numbers (on each 6 characters, you'll select only first 4), then you'll reverse it again, and then you will convert each 3 characters to ascii string (using chr())... and Viola, you'll get your string back again!

    Now i don't have time to write about strong, alpha-numeric encryptions, but if you use your imagination, you can create an unique encryption, which is almost impossible to crack...

    So, enjoy protecting your files from "normal mortals" and "want-to-be kiddies"

    Cheers, and hope this little lession helps...
    (P.S. Hope you are not confused.)
    Flash rocks!

  2. #2
    Member
    Join Date
    Sep 2002
    Posts
    98
    there is a little problem with this and that is you can not protect your source in any way,most people can scan a swf file and extract all the action script inside.
    but i should say your work is pretty nice .
    -----------------------------------------------------------------------------------------------------------------------
    I may not agree with what you say, but I will defend to the death your right to say it.

  3. #3
    Junior Member
    Join Date
    Sep 2002
    Posts
    28
    Thanks for the compliment.
    But, of course, there are many many other ways of protecting the source code.
    Flash rocks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •