Files
ClassicalCiphers.jl/test/railfence.jl
Jake W. Ireland 9cb4f1306c Added Rail Fence Cipher implementation (addresses #23)
This is only my attempt at an implementation.  @r0cketr1kky can still have another attempt, or refine my solution, but it is here now for people to use.

TODO: add better docstrings.
2021-01-08 04:48:00 +13:00

11 lines
1.1 KiB
Julia

# using ClassicalCiphers
# using Test
@test encrypt_railfence("WE ARE DISCOVERED. FLEE AT ONCE", 3) == "WECRFACERDSOEE.LETNEAIVDEO"
@test decrypt_railfence("WECRFACERDSOEE.LETNEAIVDEO", 3) == "wearediscovered.fleeatonce"
@test encrypt_railfence("Julia is strong", 10) == "JULIAISGSNTOR"
@test decrypt_railfence("JULIAISGSNTOR", 10) == "juliaisstrong"
@test encrypt_railfence("This is not a very strong cipher, but indeed it is classical", 2) == "TIINTVRSRNCPE,UIDEIICASCLHSSOAEYTOGIHRBTNEDTSLSIA"
@test decrypt_railfence("TIINTVRSRNCPE,UIDEIICASCLHSSOAEYTOGIHRBTNEDTSLSIA", 2) == "thisisnotaverystrongcipher,butindeeditisclassical"
@test construct_railfence("WE ARE DISCOVERED. FLEE AT ONCE", 3) == ['W' '□' '□' '□' 'E' '□' '□' '□' 'C' '□' '□' '□' 'R' '□' '□' '□' 'F' '□' '□' '□' 'A' '□' '□' '□' 'C' '□'; '□' 'E' '□' 'R' '□' 'D' '□' 'S' '□' 'O' '□' 'E' '□' 'E' '□' '.' '□' 'L' '□' 'E' '□' 'T' '□' 'N' '□' 'E'; '□' '□' 'A' '□' '□' '□' 'I' '□' '□' '□' 'V' '□' '□' '□' 'D' '□' '□' '□' 'E' '□' '□' '□' 'O' '□' '□' '□']