Got bored so I made an encryption program, then cut it down to 20 lines.
Here is how it works:
1. Enter a word or phrase (only letters)
2. Enter another word or phrase for the cipher text (doesn't matter the length)
3. It then prints the encrypted text on the screen
The paper way is simply adding the values of the letters. A is 1, B=2, C=3 and so on. The cipher is repeated until there are enough cipher characters for every character in the first message. It then adds the corresponding values (First letters with first letters etc). The resulting numbers are then simplified (if they are over 26 they are subtracted from) and then converted back to letters.
`Written by: Chris Bullock
`Encrypts a word or phrase using another word or phrase
restart:
`reset variables, take input
newphrase$="";input phrase$ : input cipher$
`set variables, and init arrays
phrase=len(phrase$);cipher=len(cipher$);dim values(phrase) : dim newvalues(phrase) : dim cipher(cipher)
`breaks up the input string into values, stored in values() array and checks for space-different ascii value
for count=1 to len(phrase$)
values(count)=asc(lower$(mid$(phrase$,count)))-96;if lower$(mid$(phrase$,count))=" " then values(count)=0
next count
`repeats but for the cipher
for count=1 to len(cipher$)
cipher(count)=asc(lower$(mid$(cipher$,count)))-96;if lower$(mid$(cipher$,count))=" " then cipher(count)=0
next count
`converts old message to new one
for count=1 to phrase
`see below for the actual process that is here
count#=count;cipher#=cipher;val#=count#/cipher#;val#=val#-int(val#);val#=val#*cipher#;if val#=0 then val#=cipher#
`adds the two values together to get the new value
newvalues(count)=values(count)+(cipher(val#));if newvalues(count)>27
`subtracts 27 until the new value is within the alphabet
repeat
newvalues(count)=newvalues(count)-27
until newvalues(count)<27 : endif
next count
`convert back
for count=1 to len(phrase$)
`converts the newvalues array into ascii values then into text, stored in newphrase$ also checks for space handler
newphrase$=newphrase$+chr$(newvalues(count)+96);if newvalues(count)=0 then newphrase$=newphrase$-mid$(newphrase$,len(newphrase$));newphrase$=newphrase$+" "
next count
`display and restart
print newphrase$ : goto restart
`to calculate which letter to use in the cipher, divide the character
`location by the amount of chars in the cipher then subtract int() from
`it to reveal the fraction. then multiply by how many characters are in
`the cipher string to know where to be
This should work in both dbp and dbc. It was written in dbc though, so it definitely works in that.