06-11-2003, 03:02 PM
I just finished this Encryption routine for the KetOn library yesterday:
For ciphering:
This is how you can cipher a text file:
Then try to decipher the code by hand! lol
For ciphering:
Code:
FUNCTION KT.ENC.DifCipher$(ToCipher AS STRING, Frequency AS INTEGER)
'a completely new ciphering method -> Dif Ciphering
'by Neo Deus Ex Machina
'I thought of this ciphering, it's completely new ;) lol
'It uses the difference with a sequent character from the base character
freqnow = Frequency
basechar$ = ""
ans$ = ""
FOR i = 1 TO LEN(ToCipher)
IF freqnow = Frequency THEN
freqnow = 1
basechar$ = MID$(ToCipher, i, 1)
ans$ = ans$ + basechar$
ELSE
freqnow = freqnow + 1
NewChar$ = MID$(ToCipher, i, 1)
dif% = ASC(NewChar$) - ASC(basechar$)
IF dif% >= 0 THEN
ans$ = ans$ + CHR$(dif%)
ELSE
ans$ = ans$ + CHR$(256 + dif%)
END IF
END IF
NEXT i
KT.ENC.DifCipher$ = ans$
END FUNCTION
This is how you can cipher a text file:
Code:
OPEN "MYTEXT.TXT" FOR INPUT AS #1
WHILE NOT EOF(1)
LINE INPUT #1, dat$
IF dat$ <> "" THEN PRINT KT.ENC.DifCipher$(dat$, LEN(dat$))
WEND
CLOSE #1
Then try to decipher the code by hand! lol