Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 un-crackable encyrption? possible?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
acc_minion




PostPosted: Wed Nov 26, 2003 7:22 pm   Post subject: un-crackable encyrption? possible?

Hello,

I am trying to make a program that will encrypt and decrypt, I have the very basic encryption found on this site;

EDIT: line <put "Word to Encrypt: " ..> to <put "Word's to Encrypt: " ..>

code:

   var text : string
    var codeword : string := ""
    var newletter : string

    put "Word to Encrypt: " ..
    get text : *

    for i : 1 .. length (text)

        newletter := chr (ord (text (i)) + 5)
        codeword := codeword + newletter

    end for

    put "Coded word: ", codeword, ""


However, I need this as a very complex version of the chr (ord ...) command taht will encrypt a letter into binary and then flip the binary code, then I need to be able to decrypt that code.

ie:
Enter word: blahblah
Word Encoded: 100110101010101 (or what ever)
;then;
Enter Coded Word: 100110101010101 (or what ever)
Word UnCoded: blahblah

Is this actually possible?



Code.zip
 Description:
Code as I have it now.

Download
 Filename:  Code.zip
 Filesize:  4.18 KB
 Downloaded:  215 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Wed Nov 26, 2003 8:06 pm   Post subject: (No subject)

ok... try this
note that it is necessary to return the value of encrypt as a string in order to keep any 0's at the beginning of the binary representation of a character's ascii value, which means any string you want to encrypt can't be more than 31 characters long.

so if you're trying to encrypt the contents of a file, just make sure the information is stored on lines of less than 32 characters.

code:

% canges a line of reversed binary digits into understandable text
function decrypt (BINline : string) : string
    var newline, num : string := ""

    for i : 1 .. length (BINline) by 8 % go through the whole string 8 bits (one byte) at a time
        for decreasing j : i + 7 .. i % set num to the reverse of the byte
            num += BINline (j)
        end for
        newline += chr (strint (num, 2)) % convert the byte to base 10 and use the ascii code to get the character
        num := "" % just reset num to nothing
    end for
    result newline % result the decrypted string
end decrypt

% changes a line of text into a line of reversed binary digits representing the ascii value of the string
function encrypt (TEXTline : string) : string
    var newline, num : string := ""

    for i : 1 .. length (TEXTline) % go through the whole string, one character at a time
        num := intstr (ord (TEXTline (i)), 0, 2) % convert character to it's ascii value, then convert that to binary and store in num
        num := repeat ("0", 8 - length (num)) + num % add 0's to the end of the binary number as necessary (in case the number is less than 128 and therefore less than 8 digits)
        for decreasing j : 8 .. 1 % loop from the end of the binary number to the front, in order to reverse it
            newline += num (j) % add it to the newline string
        end for
    end for
    result newline % result the encrypted string for use in the decrypt function
end encrypt

put decrypt (encrypt ("1234567890123456789012345678901"))
%put decrypt (encrypt ("12345678901234567890123456789012")) % <- this won't work


gosh, that was fun. let me know if there's anything you don't understand about that code.
Andy




PostPosted: Thu Nov 27, 2003 11:58 am   Post subject: (No subject)

what you can do is have a random increption...
the first thing you do is read in a random number, which you use to read every nth character of your encreption, then decrypt that using a mazer's encryption. now use that to find a number of other encryptions. and put ur key on every nth character. if ppl try to use your normal encryption method to decrypt your code, it wont work cuz of the nth characters. it'll mess it up completly. if they use mazer's idea, it wont work either.
Dan




PostPosted: Thu Nov 27, 2003 3:57 pm   Post subject: (No subject)

you could allways make PGP for turing Razz

PGP's ecription has yet to be broken and the code is aviable on the net for free.

also if you are giving out the scorce code for you progame poleop will be ablae to get passeted your encription b/c they will know the key worad or sequcen to decripted it.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: