mirror of
https://github.com/Smaug123/ClassicalCiphers.jl
synced 2025-10-11 20:38:39 +00:00
Add Affine functionality - encrypt, decrypt, crack
This commit is contained in:
22
test/affine.jl
Normal file
22
test/affine.jl
Normal file
@@ -0,0 +1,22 @@
|
||||
using ClassicalCiphers
|
||||
using Base.Test
|
||||
|
||||
# docs examples
|
||||
|
||||
@test encrypt_affine("Hello, World!", 3, 4) == "ZQLLU, SUDLN!"
|
||||
@test decrypt_affine("ZQLLU, SUDLN!", 3, 4) == "hello, world!"
|
||||
@test crack_affine("zqllu, sudln!") == ((3, 4), "hello, world!")
|
||||
|
||||
# Wikipedia examples
|
||||
|
||||
@test encrypt_affine("affine cipher", 5, 8) == "IHHWVC SWFRCP"
|
||||
@test decrypt_affine("IHHWVC SWFRCP", 5, 8) == "affine cipher"
|
||||
|
||||
# Practical Cryptography
|
||||
|
||||
@test encrypt_affine("defend the east wall of the castle", 5, 7) == uppercase("wbgbuw yqb bhty nhkk zg yqb rhtykb")
|
||||
@test decrypt_affine("wbgbuwyqbbhtynhkkzgyqbrhtykb", 5, 7) == "defendtheeastwallofthecastle"
|
||||
@test crack_affine("wbgbuwyqbbhtynhkkzgyqbrhtykb") == ((5, 7), "defendtheeastwallofthecastle")
|
||||
|
||||
@test crack_affine("wbgbuwyqbbhtynhkkzgyqbrhtykb", mult=5) == ((5, 7), "defendtheeastwallofthecastle")
|
||||
@test crack_affine("wbgbuwyqbbhtynhkkzgyqbrhtykb", add=7) == ((5, 7), "defendtheeastwallofthecastle")
|
@@ -1,6 +1,6 @@
|
||||
using ClassicalCiphers
|
||||
|
||||
tests = ["vigenere", "monoalphabetic", "solitaire", "caesar", "portas"]
|
||||
tests = ["vigenere", "monoalphabetic", "solitaire", "caesar", "portas", "affine"]
|
||||
|
||||
println("Running tests:")
|
||||
|
||||
|
Reference in New Issue
Block a user