Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
42
Task/Caesar-cipher/Fhidwfe/caesar-cipher.fhidwfe
Normal file
42
Task/Caesar-cipher/Fhidwfe/caesar-cipher.fhidwfe
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
lowers = ['a','z']
|
||||
uppers = ['A','Z']
|
||||
function void caesar_encode(message:ptr key:uint) {
|
||||
len = strlen$ message
|
||||
for uint [0u,len) with index {
|
||||
temp = deref_ubyte$ + message index
|
||||
if in temp lowers {
|
||||
temp = + temp key// shift lowercase letters
|
||||
if > temp 'z' {
|
||||
temp = - temp 26ub
|
||||
} ;
|
||||
} {
|
||||
if in temp uppers {
|
||||
temp = + temp key// shift uppercase letters
|
||||
if > temp 'Z' {
|
||||
temp = - temp 26ub
|
||||
} ;
|
||||
} ;//don't shift other characters
|
||||
}
|
||||
put_ubyte$ + message index temp
|
||||
}
|
||||
}
|
||||
function void caesar_decode(message:ptr key:uint) {
|
||||
caesar_encode$ message - 26u key
|
||||
}
|
||||
|
||||
key = 1u
|
||||
response = malloc$ 256u
|
||||
puts$ "plaintext: "
|
||||
getline$ response
|
||||
caesar_encode$ response key
|
||||
puts$ "cyphertext: "
|
||||
puts$ response
|
||||
putln$
|
||||
caesar_decode$ response key
|
||||
puts$ "decoded: "
|
||||
puts$ response
|
||||
free$ response
|
||||
free$ lowers // ranges are objects and must be freed
|
||||
free$ uppers
|
||||
|
||||
//this compiles with only 6 warnings!
|
||||
Loading…
Add table
Add a link
Reference in a new issue