06-08-2006, 10:03 AM
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....
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.
Life becomes easier if things are done well than being said.