Title: Encryption Theory
1Encryption Theory
- CSC380 Flint Joasaint, Marcial White
2The Algorithm
RPG Program CCED01
Originally intended for 16 digit keys, Weve
extended it to 24 digits (A-Z)
abcdefghijklmnopqrstuvwxyz bcdefghijklmnopqrst
uvwxyza cdefghijklmnopqrstuvwxyzab
defghijklmnopqrstuvwxyzabc efghijklmnopqrstuvwxyz
abcd fghijklmnopqrstuvwxyzabcde
ghijklmnopqrstuvwxyzabcdef hijklmnopqrstuvwxyzabc
defg ijklmnopqrstuvwxyzabcdefgh
jklmnopqrstuvwxyzabcdefghi klmnopqrstuvwxyzabcdef
ghij
lmnopqrstuvwxyzabcdefghijk mnopqrstuvwxyzabcdefghi
jkl nopqrstuvwxyzabcdefghijklm opqrstuvwxyzabcdefg
hijklmn pqrstuvwxyzabcdefghijklmno qrstuvwxyzabcde
fghijklmnop rstuvwxyzabcdefghijklmnopq stuvwxyzabc
defghijklmnopqr tuvwxyzabcdefghijklmnopqrs uvwxyza
bcdefghijklmnopqrst vwxyzabcdefghijklmnopqrstu
Etc
3Algorithm Continued
Program CCED01 has only one parameter a 25-byte
character value. The first 24 bytes contain a
left-justified letter. The last byte must contain
E to encrypt or D to decrypt.
CALL PGM (CCED01) PARM (Hello World E') Will
yield HDJKK QHJCT
CALL PGM (CCED01) PARM (HDJKK QHJCT D') Will
decrypt the message.
4Algorithm Continued
For decryption
Array Element abcdefghijklmnopqrstuvw
xyz bcdefghijklmnopqrstuvwxyza
cdefghijklmnopqrstuvwxyzab defghijklmnopqrstuvwxy
zabc efghijklmnopqrstuvwxyzabcd
fghijklmnopqrstuvwxyzabcde ghijklmnopqrstuvwxyzab
cdef hijklmnopqrstuvwxyzabcdefg
ijklmnopqrstuvwxyzabcdefgh jklmnopqrstuvwxyzabcde
fghi klmnopqrstuvwxyzabcdefghij
Input Letter H D J K K Q H J C T
Output Letter H E L L O W O R L D
5The Interface
6The Code
public class simple// Might randomize
placement of characters in array laterstring
characters "A","B","C","D","E","F","G","H","I",
"J","K","L","M","N","O","P","Q","R","S","T","U","V
","W","X","Y","Z"string cypertext
"!","_at_","","","","gt","","","(",")","!","_at_","
","","","gt","","","(",")","","","(",")"p
ublic simpleencrypt()public string
EncryptString(string Data, string
Key)if(Data.Length 0)throw new
ArgumentException("Hey Your key must be at please
1 digit.")uint formattedKey
FormatKey(Key)if(Data.Length2!0) Data
'\0' byte dataBytes System.Text.ASCIIEncodin
g.ASCII.GetBytes(Data)string changedtext
string.Emptyuint tempData new
uint2for(int i0 i
7The Code, Cont
- public class simple// Might randomize
placement of characters in array laterstring
characters "A","B","C","D","E","F","G","H","I",
"J","K","L","M","N","O","P","Q","R","S","T","U","V
","W","X","Y","Z"string cypertext
"!","_at_","","","","gt","","","(",")","!","_at_","
","","","gt","","","(",")","","","(",")"p
ublic simpleencrypt() - public string EncryptString(string Data, string
Key)if(Data.Length 0)throw new
ArgumentException("Hey Your key must be at please
1 digit.")uint formattedKey
FormatKey(Key)
8Code cont
- if(Data.Length2!0) Data '\0' byte
dataBytes System.Text.ASCIIEncoding.ASCII.GetByt
es(Data)string changedtext
string.Emptyuint tempData new uint2 - for( int ix 0 ix lt data.Count ix )str
( string )data ix sentences ix
str.Split( char )changedtext
Util.ConvertUIntToString(tempData0)
Util.ConvertUIntToString(tempData1)return
changedtext