mirror of
https://github.com/Smaug123/dotnet-classical-ciphers
synced 2025-10-06 13:08:40 +00:00
Initial commit
This commit is contained in:
48
CipherSuite.Test/TestAffine.fs
Normal file
48
CipherSuite.Test/TestAffine.fs
Normal file
@@ -0,0 +1,48 @@
|
||||
namespace CipherSuite.Test
|
||||
|
||||
open NUnit.Framework
|
||||
open CipherSuite
|
||||
open FsUnitTyped
|
||||
|
||||
[<TestFixture>]
|
||||
module TestAffine =
|
||||
|
||||
[<Test>]
|
||||
let ``Examples, Challenge 1`` () =
|
||||
let key, plain, fitness = Affine.crack Examples.challenge1A
|
||||
|
||||
plain.StartsWith "I WAS HOPING I WOULD FIND YOU HERE" |> shouldEqual true
|
||||
|
||||
// Note: this is the inverse of the correct key
|
||||
key |> shouldEqual (1, 19)
|
||||
|
||||
let key, plain, fitness = Affine.crack Examples.challenge1B
|
||||
|
||||
plain.StartsWith "DEAR MS FRANK," |> shouldEqual true
|
||||
|
||||
key |> shouldEqual (1, 7)
|
||||
|
||||
[<Test>]
|
||||
let ``Examples, Challenge 2`` () =
|
||||
let key, plain, fitness = Affine.crack Examples.challenge2A
|
||||
|
||||
plain.StartsWith "I MANAGED TO TRACE JADE/JODIE TO A SUITE" |> shouldEqual true
|
||||
|
||||
// Note: this is the inverse of the correct key
|
||||
key |> shouldEqual (21, 6)
|
||||
|
||||
let key, plain, fitness = Affine.crack Examples.challenge2B
|
||||
|
||||
plain.StartsWith "DEAR MS FRANK," |> shouldEqual true
|
||||
|
||||
key |> shouldEqual (3, 11)
|
||||
|
||||
[<Test>]
|
||||
let ``Examples, Challenge 3`` () =
|
||||
let key, plain, fitness = Affine.crack Examples.challenge3A
|
||||
|
||||
plain.StartsWith "JODIE ISMAK INGTH ISVER YEASY FORME HERRE CENTC"
|
||||
|> shouldEqual true
|
||||
|
||||
// Note: this is the inverse of the correct key
|
||||
key |> shouldEqual (1, 18)
|
Reference in New Issue
Block a user