Jump to content

Bacon cipher: Difference between revisions

m
→‎{{header|Agena}}: Use "if a then b else c fi" expressions instead or "a and b or c" expressions
(Added Agena)
m (→‎{{header|Agena}}: Use "if a then b else c fi" expressions instead or "a and b or c" expressions)
Line 42:
# get the Bacon code of the next character #
local plainChar := upper( plainText[ pos ] );
local code := baconCodes[ ( (if plainChar < "A" or plainChar > "Z" ) andthen "*" orelse plainChar )fi ];
for c to size code do
# copy punctuation as is from the stego template to the result
Line 49:
encoded := encoded & s;
nextStegoPos();
s := ( (if stegoPos < size stegoTemplate ) andthen upper( stegoTemplate[ stegoPos + 1 ] ) orelse "A" )fi
od;
# encode the character by changing the case of the stego character as appropriate
local templateChar := stegoTemplate[ stegoPos + 1 ];
encoded := encoded & ( (if code[ c ] = "A" ) andthen lower( templateChar ) orelse upper( templateChar ) )fi;
nextStegoPos()
od
Line 82:
then
# have a full letter to decode
decoded := decoded & ( (if codedChar > 25 ) andthen " " orelse char( abs( "a" ) + codedChar ) )fi;
letters := 0;
codedChar := 0
Line 109:
print( baconDecoded );
print( "-----------------------------------------------------" );
print( ( (if baconDecoded <> plainText ) andthen "UNSUCESSFUL" orelse "sucessful" )fi, " decode" )
epocs</lang>
{{out}}
3,048

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.