Help!!! - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html) +--- Forum: QB Projects (http://qbasicnews.com/newforum/forum-12.html) +--- Thread: Help!!! (/thread-9373.html) |
Help!!! - Polter - 06-06-2006 hello, I'm quite new here and i saw that there are quite some good alogarithms for encryption/decryption... the case is, i've made my own alogarithm in which you can enter all possible ascii characters as the cleartext,and also as the keyword... the output cipher text is in upper case alphabetic characters, which mean, it even harder to decrypt.... try some examples: output screen: ENTER WORD: ? the quick brown fox jumps over the lazy dog ENTER KEY : ? letters KEY CODE : letterslettersletterslettersletterslettersl PLAIN TEXT : the quick brown fox jumps over the lazy dog CIPHER TEXT : CJVESJYLMESTDMWPWFZCZDOGJPDLNTEKJTDUCQPPSEP and another one output screen: ENTER WORD: ? THQUICKBROWNFOXJUMPSOVERTHELAZYDOG!@#$%^&*() ENTER KEY : ? ALPHA!@#$%^&*() KEY CODE : ALPHA!@#$%^&*()ALPHA!@#$%^&*()ALPHA!@#$%^&*( PLAIN TEXT : THQUICKBROWNFOXJUMPSOVERTHELAZYDOG!@#$%^&*() CIPHER TEXT : FERNUIVJAYLYUBLVRNIEUGMADWPANNKAPZGFHFHNOOQP as you could notice, the output, whatever the input is always in the alphabet charaters only, even if your input and/or keyword is/ containing special characters if you dont mind(i'm addressing this to the reade) it's quite easy to understand the source code for the program CLS LOCATE 1, 1 INPUT "ENTER WORD: "; WORD$ INPUT "ENTER KEY : "; KEY$ KCOUNT = 0 ALPHABET$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" FOR X = 1 TO LEN(WORD$) KCOUNT = KCOUNT + 1 IF KCOUNT > LEN(KEY$) THEN KCOUNT = 1 KKEY% = ASC(MID$(KEY$, KCOUNT, 1)) - 64 CHAR% = ASC(MID$(WORD$, X, 1)) - 64 ASCNUM = CHAR% + KKEY% + 63 COUT = 0 CASCNUM = 0 DO WHILE CASCNUM < ASCNUM CASCNUM = CASCNUM + 1 COUT = COUT + 1 IF COUT > 26 THEN COUT = 1 GOODCHAR$ = MID$(ALPHABET$, COUT, 1) FOR DELAY = 1 TO 1000: NEXT DELAY LOOP KKEY$ = CHR$(KKEY% + 64) KKEY$ = KKEY$ + OLKKEY$ CHAR$ = CHR$(CHAR% + 64) CHAR$ = CHAR$ + OCHAR$ GOODCHAR$ = GOODCHAR$ + OLCHAR$ OLCHAR$ = GOODCHAR$ OLKKEY$ = KKEY$ OCHAR$ = CHAR$ LOCATE 5, 1: PRINT SPACE$(LEN(WORD$)) LOCATE 9, 1: PRINT SPACE$(LEN(WORD$)) LOCATE 13, 1: PRINT SPACE$(LEN(WORD$)) LOCATE 4, 1 PRINT "KEY CODE :" 'LOCATE 5, REV PRINT KKEY$ LOCATE 8, 1 PRINT "PLAIN TEXT :" 'LOCATE 9, REV PRINT CHAR$ LOCATE 12, 1 PRINT "CIPHER TEXT :" 'LOCATE 13, REV PRINT GOODCHAR$ NEXT X SLEEP KEYCODE$ = KKEY$ PLAINTEXT$ = CHAR$ CIPHERTEXT$ = GOODCHAR$ TXTL = LEN(WORD$) REV = 0 TREV = TXTL + 1 DO WHILE REV < TXTL FOR DELAY = 1 TO 109999: NEXT DELAY REV = REV + 1 TREV = TREV - 1 KC% = ASC(MID$(KEYCODE$, TREV, 1)) PC% = ASC(MID$(PLAINTEXT$, TREV, 1)) CIPC% = ASC(MID$(CIPHERTEXT$, TREV, 1)) KCHAR$ = CHR$(KC%) PCHAR$ = CHR$(PC%) CIPCHAR$ = CHR$(CIPC%) LOCATE 4, 1 PRINT "KEY CODE :" LOCATE 5, REV PRINT KCHAR$ LOCATE 8, 1 PRINT "PLAIN TEXT :" LOCATE 9, REV PRINT PCHAR$ LOCATE 12, 1 PRINT "CIPHER TEXT :" LOCATE 13, REV PRINT CIPCHAR$ LOOP SLEEP if someone knows how, tell me.... i have still plenty of adjustments to be done to this thing.... thanks.... Re: Help!!! - Moneo - 06-07-2006 Quote:hello,Ok, so you made your own algorithm. Now, what do you mean by "if someone knows how, tell me...." ??? What kind of help are you asking for? ***** Help!!! - Ralph - 06-07-2006 Moneo: Yes, what is his question. Polter: Good. Some things I think would be in order: 1. Establish a limit to the length of the string one may enter. Maybe 65 characters or so? 2. Establish a minimum and a maximum for the keyword. 3. Do you have a decoder for your program? 4. see Moneo's post. Help!!! - Polter - 06-07-2006 Yeah.. I forgot.... What I mean is I need to have a decoder to this type of encryption. Sounds stupid but i can't figure it out how to make a decryptor.... If i'll fail, I'll just use another alogarithms.... Help!!! - na_th_an - 06-07-2006 It can't be decoded 'cause it fails on something completely necessary: encoding using a biyective function. Right now you are encoding several source characters with the very same destination character, for example you are encoding ".", "R" and j with a "P" (not actual, just an example). When deciphering, you find a "P" and... what to choose, ".", "R" or "j"? It's like if I coded this encryption program: Code: For i% = 1 To Len (text$) Which would turn any sentence into something like "AAABBBABBABABBABABBABAAABABABBBBABABAAABBA". Now... how to decrypt? Impossible: you are losing information with the encryption. Help!!! - Polter - 06-07-2006 Thanks for reminding me about that... I forgot to look at the results... I'll just recode it so that it can have a decryptor.... Help!!! - Skyler - 06-07-2006 You could always try implementing the XOR function somewhere... Help!!! - Moneo - 06-08-2006 Quote:Thanks for reminding me about that... I forgot to look at the results... I'll just recode it so that it can have a decryptor....Here's a very good, simple XOR encryption and decryption algorithm originally written by Ethan Winer. Try it out. Code: rem X$ is the string to be encrypted or decrypted. Help!!! - Ralph - 06-08-2006 Moneo: I tried the code in QuickBASIC 4.5. I had to change the X$ to S$, as the use of X and X$ kept giving me an error. Then, encryping the simple word "THIS" returns a heart)/2. Now, since the heart is not your "usual" keyboard entry character, it becomes very dificult to de-crypt the encrypted code! I think that an encrypter/decrypter should return only keyboard characters, to make it truly useful. What do you think? Help!!! - Polter - 06-08-2006 I like the XOR alogarithm but i what i have in mind right now is to make an alogarithm which employs the use of vigenere table and other old stuff, combined which can make a stronger alogarithm... |