Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

cryption

ghost13ghost13 Posts: 250Member
I'm looking 4 some encryption algorithms, not very strong (complex) but fairly secure

The Ghost
ghost@crazygrandpa.com

Comments

  • nightsurfernightsurfer Posts: 272Member
    How good do you need? Some of the good encryption algorithms involve matrices and their identities, where to move forward and backwards through the message you would have to multiply by the identity matrix. I can't remember all the details of this algorithm, but if you want it, I can look it up later and send it to you. You would have to know something about matrices to use, though.

    There are two methods in software design. One is to make the program so simple that there are obviously no flaws, the other is to make the program so complicated that there are no obvious flaws.

  • ghost13ghost13 Posts: 250Member
    something for a part of an app. not VERY stupid and obvious but not Rijndle (is that how u write it ?!)

    The Ghost
    ghost@crazygrandpa.com

  • nightsurfernightsurfer Posts: 272Member
    OK, how's this for an algorithm? It's not complicated at all, but it would not be obvious how to crack it, since even you won't know the actual key. You create a string that contains all the letters and characters that you want to use, in any order. Make a copy of the string. In a loop that goes until the copy is empty, remove a random character from the string and put it in a new string. You will now have three strings: 1 with an ordered sequence of characters, 1 empty, and 1 with a randomly ordered collection of the same characters.
    You then take your message and parse it letter by letter, and replace each character with the character at the same location in teh third string. (If the first string is "ABCDE" and the second is "" and the third is "DBEAC" then all A's become D's and all B's stay the same, all C's become E's, etc..). Then when you want to decrypt it, you have to pass the string to be decrypted along with the two strings containing the list of characters that have been exchanged. Note that you do not need to change every character used, but all the A's must be changed (just an example). You can also run the string through multiple times, where it would become a little more encrypted, and would take the same number of runs backwards to decrypt it.

    Hope this helps.


    There are two methods in software design. One is to make the program so simple that there are obviously no flaws, the other is to make the program so complicated that there are no obvious flaws.

  • Eric TetzEric Tetz Posts: 2,141Member
    : OK, how's this for an algorithm? It's not complicated at all

    Here's one that's even simpler, and turns the message into complete white noise - random garbage. It requires an integer key, which is used to encrypt and decrypt the message.

    Encrypt:
    1) seed random number generator with key
    2) add random number to each byte in the data

    Decrypt:
    1) seed random number generator with key
    2) subtract random number from each byte in the data

    That's it. Yes, it's crackable, especially if you use the stock random number generator of a popular compiler, or if the number generator repeats itself before the end of the message (would require a giant message, or a lousy random number generator). However, it would require a pretty knowledgeable cracker.
    [code=ffffff]
    [color=a020f0]#include [/color][color=bb0000][/color]
    [color=a020f0]#include [/color][color=bb0000][/color]

    [color=000080]void[/color] encrypt ([color=000080]unsigned[/color] [color=000080]int[/color] key, [color=000080]unsigned[/color] [color=000080]char[/color]* data, [color=000080]size_t[/color] len) {
    srand(key);
    [color=000080][b]const[/b][/color] [color=000080]unsigned[/color] [color=000080]char[/color]* end = data + len;
    [color=000000][b]while[/b][/color] (data < end)
    *data++ += rand();
    }

    [color=000080]void[/color] decrypt ([color=000080]unsigned[/color] [color=000080]int[/color] key, [color=000080]unsigned[/color] [color=000080]char[/color]* data, [color=000080]size_t[/color] len) {
    srand(key);
    [color=000080][b]const[/b][/color] [color=000080]unsigned[/color] [color=000080]char[/color]* end = data + len;
    [color=000000][b]while[/b][/color] (data < end)
    *data++ -= rand();
    }

    [color=000080]int[/color] main()
    {
    [color=000080]unsigned[/color] [color=000080]char[/color] data[] = [color=bb0000]"This is a test of the encryption algorithm."[/color];

    [color=000080]size_t[/color] len = [color=000000][b]sizeof[/b][/color](data) - [color=bb0000]1[/color];

    [color=000080]int[/color] key = [color=bb0000]777[/color];

    encrypt (key, data, len);
    puts (data);

    decrypt (key, data, len);
    puts (data);

    [color=000000][b]return[/b][/color] [color=bb0000]0[/color];
    }
    [/code]
    Cheers,
    Eric

  • zibadianzibadian Posts: 6,349Member
    A variation on this algorithm uses a password.

    This algorithm uses three strings: a message string, a password string, and an encrypted message string.
    You simply perform a mathematical expression taking the letters from the message and the password to encrypt a new string. The most simple being an ASCII-addition, example:

    Message: Encryption algorithm
    Password: code

    - Take the first letter of the message and the password, and add them:

    E (ASCII 69) + c(ASCII 99) = (ASCII 168)

    - then the second, third etc. until you reach the end of the password.
    - Now you have a problem, since you cannot add any more letters to the message letters. Solution: start over with the password.

    In this case: the fifth letter (y) is encrypted with the C of the password.
    The encrypted message looks like this: __+?F?
    Which is utter garbage.

    P.S. Here is the Delphi code, which produced this message:
    [code]
    var
    msg:string = 'Encryption algorithm';
    pw:string = 'code';
    emsg:string;
    pwindex,msgindex:integer;
    begin
    pwindex:=1;
    for msgindex:=1 to length(msg) do begin
    emsg:=emsg+char(byte(msg[msgindex])+byte(pw[pwindex]))+' ';
    inc(pwindex);
    if pwindex>length(pw) then
    pwindex:=1;
    end;
    end;
    [/code]

  • Eric TetzEric Tetz Posts: 2,141Member
    : A variation on this algorithm uses a password.

    The algorithm I showed uses a password, too.

    : This algorithm uses three strings: a message string, a password string, and an encrypted message string.
    : You simply perform a mathematical expression taking the letters from the message and the password to encrypt a new string. The most simple being an ASCII-addition, example:
    :
    : Message: Encryption algorithm
    : Password: code
    :
    : - Take the first letter of the message and the password, and add them:
    :
    : E (ASCII 69) + c(ASCII 99) = (ASCII 168)
    :
    : - then the second, third etc. until you reach the end of the password.
    : - Now you have a problem, since you cannot add any more letters to the message letters. Solution: start over with the password.
    :
    : In this case: the fifth letter (y) is encrypted with the C of the password.
    : The encrypted message looks like this: __+?F?
    : Which is utter garbage.

    Not [italic]really[/italic] utter garbage. In your example, the alteration of the message repeats every 4 characters! The kind of thing easy for a computer to spot. Actually, this one's easy enough for a human to spot. Imagine some blank space in the message, like:
    [code=ffffff]
    original = ' '
    encrypted = ''
    [/code]
    If we look at the value of each byte:

    131 143 132 133 131 143 132 133 131 143 132 133 131 143 132 133 131 143 132

    It doesn't take a master hacker to see that it repeats. Here's the same blank space encrypted with the algorithm I posted.
    [code=ffffff]
    original = ' '
    encrypted = '-Sn' a-l?z-q ' (mostly non-printable chars)

    [/code]

    186 196 83 252 145 247 39 247 0 97 45 108 169 160 14 122 45 113 199

    Utter garbage. ;)

    Cheers,
    Eric




  • zibadianzibadian Posts: 6,349Member
    : : A variation on this algorithm uses a password.
    :
    : The algorithm I showed uses a password, too.
    :
    : : This algorithm uses three strings: a message string, a password string, and an encrypted message string.
    : : You simply perform a mathematical expression taking the letters from the message and the password to encrypt a new string. The most simple being an ASCII-addition, example:
    : :
    : : Message: Encryption algorithm
    : : Password: code
    : :
    : : - Take the first letter of the message and the password, and add them:
    : :
    : : E (ASCII 69) + c(ASCII 99) = (ASCII 168)
    : :
    : : - then the second, third etc. until you reach the end of the password.
    : : - Now you have a problem, since you cannot add any more letters to the message letters. Solution: start over with the password.
    : :
    : : In this case: the fifth letter (y) is encrypted with the C of the password.
    : : The encrypted message looks like this: __+?F?
    : : Which is utter garbage.
    :
    : Not [italic]really[/italic] utter garbage. In your example, the alteration of the message repeats every 4 characters! The kind of thing easy for a computer to spot. Actually, this one's easy enough for a human to spot. Imagine some blank space in the message, like:
    : [code=ffffff]
    : original = ' '
    : encrypted = ''
    : [/code]
    : If we look at the value of each byte:
    :
    : 131 143 132 133 131 143 132 133 131 143 132 133 131 143 132 133 131 143 132
    :
    : It doesn't take a master hacker to see that it repeats. Here's the same blank space encrypted with the algorithm I posted.
    : [code=ffffff]
    : original = ' '
    : encrypted = '-Sn˜'˜ a-l?z-q ' (mostly non-printable chars)
    :
    : [/code]
    :
    : 186 196 83 252 145 247 39 247 0 97 45 108 169 160 14 122 45 113 199
    :
    : Utter garbage. ;)
    :
    : Cheers,
    : Eric
    :
    :
    :
    :
    :
    That is correct, but this was merely a simple example. Normally I use much more complicated formulas, and combine it with completely other encryption algorithms, such as a transformation matrix or a simple compression.
Sign In or Register to comment.