KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm writing a simple rc4 encryption/decryption utility as a first project. I'm stuck on trying to convert the given string into an array of bytes that can then be manipulated by the core algorithm. How do you convert a string into an array of bytes in functional f#? //From another thread let private replace find (repl : string) (str : string) = str.Replace(find, repl) //let private algorithm bytes = blah blah blah let Encrypt (decrypted : string) = decrypted.Chars |> Array.map(fun c -> byte.Parse(c)) // This line is clearly not working // |> algorithm |> BitConverter.ToString |> replace "-" "" FYI in C# it looks like: public static string Encrypt(string decrypted) { byte[] bytes = new byte[decrypted.Length]; for (int i = 0; i < decrypted.Length; ++i) bytes[i] = (byte)decrypted[i]; Algorithm(ref bytes); return BitConverter.ToString(bytes).Replace("-", "").ToLower(); }
Tags (comma-separated)
Save Edits
Cancel