0 people like it.
Like the snippet!
Incorrect implementation, correct theory of cracking
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
|
let wl = System.IO.File.ReadAllLines("C:\Users\pc\Desktop\wordlist.txt")
module caesar =
let cipher (k: int) (m: string) =
Seq.toArray(m)
|> Array.map (fun c ->
if int c = 32
then c
else ((int c - 97 + k) % 26 + 97) |> char)
|> (fun s -> new string(s))
let encrypt k = cipher k
let decrypt k = cipher (26 - k)
let checkWl d =
Array.filter(fun x -> d = x)wl
(* below here is highly incorrect, but it works *)
let run (d: string) =
Array.map(fun x -> caesar.decrypt x (d.ToLower()))[|1..25|]
|> Array.map (fun x ->
(x.Split ' ')
|> Array.map (fun x -> checkWl x))
|> Array.concat
|> Array.concat (*woops * 2 this is highly uneconomic*)
|> Array.iter(fun x -> printfn "%s" x)
run (caesar.encrypt 13 "today is cold")
|
val wl : string []
Full name: Script.wl
namespace System
namespace System.IO
type File =
static member AppendAllLines : path:string * contents:IEnumerable<string> -> unit + 1 overload
static member AppendAllText : path:string * contents:string -> unit + 1 overload
static member AppendText : path:string -> StreamWriter
static member Copy : sourceFileName:string * destFileName:string -> unit + 1 overload
static member Create : path:string -> FileStream + 3 overloads
static member CreateText : path:string -> StreamWriter
static member Decrypt : path:string -> unit
static member Delete : path:string -> unit
static member Encrypt : path:string -> unit
static member Exists : path:string -> bool
...
Full name: System.IO.File
System.IO.File.ReadAllLines(path: string) : string []
System.IO.File.ReadAllLines(path: string, encoding: System.Text.Encoding) : string []
val cipher : k:int -> m:string -> string
Full name: Script.caesar.cipher
val k : int
Multiple items
val int : value:'T -> int (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.int
--------------------
type int = int32
Full name: Microsoft.FSharp.Core.int
--------------------
type int<'Measure> = int
Full name: Microsoft.FSharp.Core.int<_>
val m : string
Multiple items
val string : value:'T -> string
Full name: Microsoft.FSharp.Core.Operators.string
--------------------
type string = System.String
Full name: Microsoft.FSharp.Core.string
module Seq
from Microsoft.FSharp.Collections
val toArray : source:seq<'T> -> 'T []
Full name: Microsoft.FSharp.Collections.Seq.toArray
module Array
from Microsoft.FSharp.Collections
val map : mapping:('T -> 'U) -> array:'T [] -> 'U []
Full name: Microsoft.FSharp.Collections.Array.map
val c : char
Multiple items
val char : value:'T -> char (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.char
--------------------
type char = System.Char
Full name: Microsoft.FSharp.Core.char
val s : char []
val encrypt : k:int -> (string -> string)
Full name: Script.caesar.encrypt
val decrypt : k:int -> (string -> string)
Full name: Script.caesar.decrypt
val checkWl : d:string -> string []
Full name: Script.checkWl
val d : string
val filter : predicate:('T -> bool) -> array:'T [] -> 'T []
Full name: Microsoft.FSharp.Collections.Array.filter
val x : string
val run : d:string -> unit
Full name: Script.run
val x : int
module caesar
from Script
System.String.ToLower() : string
System.String.ToLower(culture: System.Globalization.CultureInfo) : string
System.String.Split([<System.ParamArray>] separator: char []) : string []
System.String.Split(separator: string [], options: System.StringSplitOptions) : string []
System.String.Split(separator: char [], options: System.StringSplitOptions) : string []
System.String.Split(separator: char [], count: int) : string []
System.String.Split(separator: string [], count: int, options: System.StringSplitOptions) : string []
System.String.Split(separator: char [], count: int, options: System.StringSplitOptions) : string []
val concat : arrays:seq<'T []> -> 'T []
Full name: Microsoft.FSharp.Collections.Array.concat
val iter : action:('T -> unit) -> array:'T [] -> unit
Full name: Microsoft.FSharp.Collections.Array.iter
val printfn : format:Printf.TextWriterFormat<'T> -> 'T
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
More information