Good points, David.  I was assuming that the teacher required all coding
to be done by the student.  In that case, go right ahead and use
libraries.  I don't know what kind of class this is, but if this is more
of an intro level class, you could always just do a shift cipher (add some
number n to each character).  This is trivial to break, but it'll let you
make an encrypt() function that actually does something (without doing
much work).  You could also do one-time-pad encryption, which is
impossible to break (unless through social-engineering).  This is done as
follows:  
1) Pick a key of length n, where n is the length of the message you want
to send.
2) At each position p of the message, add it to the position p of the key
(mod 27 or however many characters you are supporting).
3) to decrypt, simply subtract the key (mod whatever).

Example:
key:no
mesg: hi
7+13 8+14 = 20,22
ciphertext: uw

The downside to this is that you can only use a one-time-pad once.  So
generation is an issue (you could also use Linear Feedback Shift
Registers, which would be easy to code up.  Just do a search on google).

--Brannon Smith


Reply via email to