Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help!!!
#11
Actually, now, I have made this program implementing the vigenere alogarithms which follows:

NOTE:
c = cipher
p = plain
k = key

to encrypt:

C = (P+K) MOD 26

to decrypt

P = (C-K+26) MOD 26


Here's the code:



CLS


LOCATE 1, 1
INPUT "ENTER WORD: "; WORD$
WORD$ = UCASE$(WORD$)
LOCATE 1, 15
PRINT WORD$
INPUT "ENTER KEY : "; KEY$
KEY$ = UCASE$(KEY$)
LOCATE 2, 15
PRINT KEY$

Y = 0
P = 0
K = 0
C = 0

FOR X = 1 TO LEN(WORD$)

Y = Y + 1

IF Y > LEN(KEY$) THEN Y = 1

P = ASC(MID$(WORD$, X, 1)) - 65
K = ASC(MID$(KEY$, Y, 1)) - 65

C = (P + K) MOD 26

CIPHER$ = CHR$(C + 65)
CIPHER$ = CIPHER$ + OCIPHER$

OCIPHER$ = CIPHER$

NEXT

PRINT "CIPHER :"
LOCATE 3, 15
PRINT CIPHER$

YY = 0
PP = 0
CC = 0
KK = 0




It works, but only alphabetic characters can be used, not even space....
I'm still in trouble finding out how to decrypt... I've tried the formula, but it still outputs garbled plaintext....


here's where i got my idea
britanica encyclopedia (old book at my high school library)
http://en.wikipedia.org/wiki/Vigenere_table

I'll try to expand the charset of the proram to use the whole ASCII charset....
aith without action is dead.
Life becomes easier if things are done well than being said.
Reply
#12
FINALLY!!!!!

I've done my Vigenere program!!!! It really works!!!
A Text encryptor/Decryptor for alphabetic characters

Here's the code....

CLS
CLEAR

LOCATE 1, 1
INPUT "ENTER WORD: "; WORD$
WORD$ = UCASE$(WORD$)
LOCATE 1, 15
PRINT WORD$
INPUT "ENTER KEY : "; KEY$
KEY$ = UCASE$(KEY$)
LOCATE 2, 15
PRINT KEY$

Y = 0
P = 0
K = 0
C = 0

FOR X = 1 TO LEN(WORD$)

Y = Y + 1
IF Y > LEN(KEY$) THEN Y = 1

P = ASC(MID$(WORD$, X, 1)) - 65
K = ASC(MID$(KEY$, Y, 1)) - 65
C = (P + K) MOD 26

CIPHER$ = CHR$(C + 65)
CIPHER$ = OCIPHER$ + CIPHER$
OCIPHER$ = CIPHER$

NEXT

PRINT "CIPHER :"
LOCATE 3, 15
PRINT CIPHER$


LOCATE 6, 1
INPUT "ENTER CIPHER: "; CCIPHER$
CCIPHER$ = UCASE$(CCIPHER$)
LOCATE 6, 17
PRINT CCIPHER$
INPUT "ENTER KEY : "; KKEY$
KKEY$ = UCASE$(KKEY$)
LOCATE 7, 17
PRINT KKEY$


YY = 0
PP = 0
CC = 0
KK = 0


FOR XX = 1 TO LEN(CCIPHER$)

YY = YY + 1
IF YY > LEN(KKEY$) THEN YY = 1

CC = ASC(MID$(CCIPHER$, XX, 1)) - 65
KK = ASC(MID$(KKEY$, YY, 1)) - 65
PP = (CC - KK + 26) MOD 26

PLAIN$ = CHR$(PP + 65)
PLAIN$ = OPLAIN$ + PLAIN$
OPLAIN$ = PLAIN$

NEXT

PRINT "PLAIN :"
LOCATE 8, 17
PRINT PLAIN$



this nice for "secret messages" even though this does not support numeric and special characters.....
I recommend to use a key whose length is same as the plaintext...

I'll recode this to make use of the full ASCII code....

I'll also try to make an alogrithm to be combined with this....
It's called the one time pad... a secure and uncrackable encryption...

got the idea from
http://en.wikipedia.org/wiki/One-time_pad
aith without action is dead.
Life becomes easier if things are done well than being said.
Reply
#13
Polter:

Congratulations! There is nothing that produces success as determination and action, which you have demonstrated. Keep up your positive approach to all problems, and your life will be full of successes! We all applaud your winning attitude.
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply
#14
Quote: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?
Ralph,
Sorry about the X and X$ issue. Some compilers allow it, others do not. Anyway, that's the way Ethan Winer wrote it.

I don't agree with an encryption algorithm returning only keyboard characters. The purpose of an encryption algorithm is to take a string or record of characters and convert it or scramble it in such a way, using a password, so that the original text will not be recognizable. Of course, you should be able to run the same algorithm and password to convert the encrypted text back to the original.

I have never heard of the requirement that the encrypted text should be keyboard characters only. What's the purpose?

The algorithm is given a text and a password, it produces an encrypted text which can be stored on a file. When you want to decrypt the text, you read the encrypted text from the file, and run the algorithm on it with the same password.

If someone wants to look at the encrypted text, he will use a hex editor, because he will not be expecting keyboard characters.
*****
Reply
#15
Moneo:

Thanks for your explanations. I am not really into encryption, so I think that one would receive an encripted message from someone, say on a piece of paper, then one would turn to the computer, get the decrypter running, and type in the message.

Using your method, i guess the encrypted code would come in as an email or attachment, then one would read it, either with the decryption program directly, or with some editor that would allow a file to be made, then the decrypter would read that file and print out the message.

Does the above come close?
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply
#16
Actually, when I made an encryptor/decryptor combo, it encrypted on a file-by-file basis. For example,

encrypt test.txt password

I also experimented with a vignere encryption routine which used the whole ASCII table, but I deleted it. I think.
In the beginning, there is darkness – the emptiness of a matrix waiting for the light. Then a single photon flares into existence. Then another. Soon, thousands more. Optronic pathways connect, subroutines emerge from the chaos, and a holographic consciousness is born." -The Doctor
Reply
#17
Actually, when I made an encryptor/decryptor combo, it encrypted on a file-by-file basis. For example,

encrypt test.txt password

I also experimented with a vignere encryption routine which used the whole ASCII table, but I deleted it. I think. It set up an array and filled it vignere-style with the ASCII chars, then encrypted anything you passed to the function.
In the beginning, there is darkness – the emptiness of a matrix waiting for the light. Then a single photon flares into existence. Then another. Soon, thousands more. Optronic pathways connect, subroutines emerge from the chaos, and a holographic consciousness is born." -The Doctor
Reply
#18
What is vignere?
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply
#19
Quote:Moneo:

Thanks for your explanations. I am not really into encryption, so I think that one would receive an encripted message from someone, say on a piece of paper, then one would turn to the computer, get the decrypter running, and type in the message.

Using your method, i guess the encrypted code would come in as an email or attachment, then one would read it, either with the decryption program directly, or with some editor that would allow a file to be made, then the decrypter would read that file and print out the message.

Does the above come close?
Yes, I think you have the idea.

For the piece of paper version, yes, you would need to have a modified encryption algorithm that produced only printable characters. Starting with the Ethan Winer algorithm that I gave you, it could be modified to this end.

Email would not be good to contain the encrypted text. You would have to put it into an attachment, and probably set the file extension to .TXT to let the email system accept it. You have to do the same thing when sending executable files.

You would feed the encrypted file directly into the encrypt/decrypt program. Forget about the editor stuff.

Let me know if you need more help with this.
*****
Reply
#20
Moneo:

Thanks for the explanations, and for the offer to help further. As I said, I am not into encryption, so, thank you again, but now, what you have already provided is fine.
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)