Add decipher function.
[rup.git] / WebSharper / Crypto.fs
index 5ad3d99..f85825f 100644 (file)
@@ -21,6 +21,7 @@ let generateKey () : Key =
     let bytes = randBytes (keySize / 8)\r
     Convert.ToBase64String bytes |> WebUtility.UrlEncode\r
 \r
+// TODO: return a Result<string, EncryptError>\r
 let encrypt (key : Key) (name : string) : string =\r
     let keyAsBytes = WebUtility.UrlDecode key |> Convert.FromBase64String\r
     let iv = randBytes (keySize / 8)\r
@@ -45,6 +46,7 @@ let encrypt (key : Key) (name : string) : string =
     stream.Read (result, iv.Length + hash.Length, int stream.Length) |> ignore\r
     "1" + Convert.ToBase64String result |> WebUtility.UrlEncode\r
 \r
+// TODO: return a Result<string, DecryptError>\r
 let decrypt (key : Key) (cipher : string) (urlDecode : bool) : string =\r
     let version = cipher.Substring (0, 1) |> int\r
     if version <> 1 then\r