<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: How to write a cryptographic game program in c language?</title> <atom:link href="http://www.howto.com.my/2009/answer-this-if-you-can/how-to-write-a-cryptographic-game-program-in-c-language/feed/" rel="self" type="application/rss+xml" /><link>http://www.howto.com.my/2009/answer-this-if-you-can/how-to-write-a-cryptographic-game-program-in-c-language/</link> <description>Your How To Solution For Just About Everything</description> <lastBuildDate>Fri, 20 Jan 2012 12:43:10 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>By: Nick T</title><link>http://www.howto.com.my/2009/answer-this-if-you-can/how-to-write-a-cryptographic-game-program-in-c-language/comment-page-1/#comment-19714</link> <dc:creator>Nick T</dc:creator> <pubDate>Fri, 18 Dec 2009 09:02:13 +0000</pubDate> <guid
isPermaLink="false">http://www.howto.com.my/2009/answer-this-if-you-can/how-to-write-a-cryptographic-game-program-in-c-language/#comment-19714</guid> <description>Obviously your homework. The general idea is that YOU do it to reinforce the concepts covered in class. Expecting others to do it for you means you will never learn to think for yourself.
From the sounds of it this is a straightforward substitution cypher system, each character is replaced by another, it offers a minimal amount of security.
The following is rather verbose pseudo code, it could be simplified, i.e. use a single encode decode function, but is for readability.
You could also expand the concept to allow the plainText to be extended via the update routine.
PSEUDO CODE
declare PlainText as character array size (NUMBER OF SUPPORTED CHARACTERS)
declare EncryptionKey as character array size (NUMBER OF SUPPORTED CHARACTERS)
declare Text as string
declare Flag as boolean value True
declare EncryptionKeyValid  as boolean value False
EncryptionKeyValid = read Encryption Key from File
LOOP WHILE ( Flag )
..IF ( EncryptionKeyValid ) THEN
....Show Menu
....get UserSelection
..ELSE
....UserSelection =  Enter New Encryption Key
..END IF
..IF ( Encode Message Selected ) THEN
....output Enter Message to be Encoded
....get Text
....Encode Text using EncryptionKey
..ELSE IF ( Decode Message Selected ) THEN
....output Enter Message to be Decoded
....get Text
....Decode Text using EncryptionKey
..ELSE IF ( Enter New Encryption Key Selected ) THEN
....output Enter New Encryption Key for the following characters
....output PlainText
....get Text
....IF ( Validate Encryption Key(Text)  ) THEN
......EncryptionKeyValid  = True
......EncryptionKey  =Text
......Save EncryptionKey to File
......output Encryption Key Updated.
....ELSE
......output ERROR : Encryption Key entered failed validation. Old Key retained.
....END IF
..ELSE IF ( Exit selected ) THEN
....clear Flag
..END IF
END LOOP
Encode
..declare valid as boolean value True
..LOOP FOR EACH character in inputText
....index = Find(character in PlainText)
....IF ( index is valid ) THEN
......output character from EncryptionKey (element index)
....ELSE
......output ERROR - Invalid/unsupported character &quot;(character)&quot; in input string
......valid  = False
....END IF
..END LOOP
END Encode (return valid)
Decode
..declare valid as boolean value True
..LOOP FOR EACH character in inputText
....index = Find(character in EncryptionKey )
....IF ( index is valid ) THEN
......output character from PlainText(element index)
....ELSE
......output ERROR - Invalid/unsupported character &quot;(character)&quot; in input string
......valid = False
....END IF
..END LOOP
END Decode (return valid)
Validate Encryption Key
..declare valid as boolean value True
..IF ( Length of inputText matches (NUMBER OF SUPPORTED CHARACTERS) ) THEN
....LOOP FOR (NUMBER OF SUPPORTED CHARACTERS)
......count occurances of character in inputText
......IF ( count is greater than 1) THEN
........valid = False
......END IF
....END LOOP
..ELSE
....valid = False
..END IF
END Validate Encryption Key (return valid)</description> <content:encoded><![CDATA[<p>Obviously your homework. The general idea is that YOU do it to reinforce the concepts covered in class. Expecting others to do it for you means you will never learn to think for yourself.</p><p>From the sounds of it this is a straightforward substitution cypher system, each character is replaced by another, it offers a minimal amount of security.</p><p>The following is rather verbose pseudo code, it could be simplified, i.e. use a single encode decode function, but is for readability.</p><p>You could also expand the concept to allow the plainText to be extended via the update routine.</p><p>PSEUDO CODE</p><p>declare PlainText as character array size (NUMBER OF SUPPORTED CHARACTERS)<br
/> declare EncryptionKey as character array size (NUMBER OF SUPPORTED CHARACTERS)<br
/> declare Text as string</p><p>declare Flag as boolean value True<br
/> declare EncryptionKeyValid  as boolean value False</p><p>EncryptionKeyValid = read Encryption Key from File</p><p>LOOP WHILE ( Flag )<br
/> ..IF ( EncryptionKeyValid ) THEN<br
/> &#8230;.Show Menu<br
/> &#8230;.get UserSelection<br
/> ..ELSE<br
/> &#8230;.UserSelection =  Enter New Encryption Key<br
/> ..END IF</p><p>..IF ( Encode Message Selected ) THEN<br
/> &#8230;.output Enter Message to be Encoded<br
/> &#8230;.get Text<br
/> &#8230;.Encode Text using EncryptionKey<br
/> ..ELSE IF ( Decode Message Selected ) THEN<br
/> &#8230;.output Enter Message to be Decoded<br
/> &#8230;.get Text<br
/> &#8230;.Decode Text using EncryptionKey<br
/> ..ELSE IF ( Enter New Encryption Key Selected ) THEN<br
/> &#8230;.output Enter New Encryption Key for the following characters<br
/> &#8230;.output PlainText<br
/> &#8230;.get Text<br
/> &#8230;.IF ( Validate Encryption Key(Text)  ) THEN<br
/> &#8230;&#8230;EncryptionKeyValid  = True<br
/> &#8230;&#8230;EncryptionKey  =Text<br
/> &#8230;&#8230;Save EncryptionKey to File<br
/> &#8230;&#8230;output Encryption Key Updated.<br
/> &#8230;.ELSE<br
/> &#8230;&#8230;output ERROR : Encryption Key entered failed validation. Old Key retained.<br
/> &#8230;.END IF<br
/> ..ELSE IF ( Exit selected ) THEN<br
/> &#8230;.clear Flag<br
/> ..END IF<br
/> END LOOP</p><p>Encode<br
/> ..declare valid as boolean value True<br
/> ..LOOP FOR EACH character in inputText<br
/> &#8230;.index = Find(character in PlainText)<br
/> &#8230;.IF ( index is valid ) THEN<br
/> &#8230;&#8230;output character from EncryptionKey (element index)<br
/> &#8230;.ELSE<br
/> &#8230;&#8230;output ERROR &#8211; Invalid/unsupported character &quot;(character)&quot; in input string<br
/> &#8230;&#8230;valid  = False<br
/> &#8230;.END IF<br
/> ..END LOOP<br
/> END Encode (return valid)</p><p>Decode<br
/> ..declare valid as boolean value True<br
/> ..LOOP FOR EACH character in inputText<br
/> &#8230;.index = Find(character in EncryptionKey )<br
/> &#8230;.IF ( index is valid ) THEN<br
/> &#8230;&#8230;output character from PlainText(element index)<br
/> &#8230;.ELSE<br
/> &#8230;&#8230;output ERROR &#8211; Invalid/unsupported character &quot;(character)&quot; in input string<br
/> &#8230;&#8230;valid = False<br
/> &#8230;.END IF<br
/> ..END LOOP<br
/> END Decode (return valid)</p><p>Validate Encryption Key<br
/> ..declare valid as boolean value True<br
/> ..IF ( Length of inputText matches (NUMBER OF SUPPORTED CHARACTERS) ) THEN<br
/> &#8230;.LOOP FOR (NUMBER OF SUPPORTED CHARACTERS)<br
/> &#8230;&#8230;count occurances of character in inputText<br
/> &#8230;&#8230;IF ( count is greater than 1) THEN<br
/> &#8230;&#8230;..valid = False<br
/> &#8230;&#8230;END IF<br
/> &#8230;.END LOOP<br
/> ..ELSE<br
/> &#8230;.valid = False<br
/> ..END IF<br
/> END Validate Encryption Key (return valid)</p> ]]></content:encoded> </item> </channel> </rss>
