Sorry its in python, I have yet to make it in C++. But I made a puzzle maker like the newspapers, using ceasar cypher. I have to make the a-z circular so that it stays within a-z. and I have to add a random generator for the shift, but knowing the shift value can be used for the decoder. I was intereseted in the different cyphers, especially the one that uses a word as a shift, some french name. This program is trivial to me so I don't care if I share it, its a derivitive of an encoding program. I made it so it will print the spaces, and punctiation in the output. It might give you a look to see how easy python is to code. You should be able to see the similiarity's.
# A program that uses Ceaser cipher to encode a message by shifting the plain
# text message to a fixed number
import string #include string library for split function
def main():
print "Function name: text2numbers()"
print "Function name: numbers2text()"
text2numbers()
#text2numbers
# A program to convert a textual message into a sequence of
# numbers, utilizing the underlying ASCII encoding.
def text2numbers():
print "This program converts a textual message into a sequence"
print "of numbers representing the ASCII encoding of the message."
print
#Get the message to encode.
message = raw_input("Please enter the message to encode: ")
x = input("Enter number to shift: ")
print
print "Here are the codes:"
#Loop through the message and print out the ASCII values
for ch in message:
newch = ord(ch) + x #this is where you shift
if newch == 32 + x:
print " ",
elif newch == 44 + x:
print ","
elif newch == 39 + x:
print "'",
elif newch == 46 + x:
print "."
elif newch == 59 + x:
print ";"
elif newch != 32 + x:
print newch, #use comma to print all on one line
#numbers2text
# A program to convert a sequence of ASCII numbers into a string of text.
def numbers2text():
print "This program converts a sequence of ASCII numbers into"
print "the string of text that it represents."
print
#Get the message to encode
inString = raw_input("Please enter the ASCII-encoded message: ")
x = input("Enter the shift: ")
#Loop through each substring and build ASCII message
message = ""
newString = []
for numStr in string.split(inString):
asciiNum = eval(numStr) #convert digits to number
newString.append(chr(asciiNum - x))
newString1 = string.join(newString, "")
#message = message + chr(asciiNum) #append character to message
#print "The decoded message is:" , message
print newString1
main()
sorry I don't have any c++ creations as of yet. the one I think thats really cool is converting from a number in range of 1-256 to output its 8bit binary number. converting from binary to int was easier, and I like this forum so I won't post tons of python code. Just wanted to share. I know that people can't just post other languages, because I know that some people know alot more and its confusing, but pythons really simple. And pythons a free download at python.org. Just if anyones interested. I got bored of python though, so I took up C++