title: How can i create an xor function in F# which can encrypt a byte array?
body: <p>How can i create an xor function in F# which can encrypt a byte array? There is this code here which i got from Github but it encrypts a string.</p>
  <pre><code>open System
  
  let encrypt (word : string) = 
      let key = &quot;KCQ&quot;
      [ 0..(word.Length - 1) ]
      |&gt; Seq.map (fun idx -&gt; Convert.ToChar(Convert.ToInt32 word.[idx] ^^^ Convert.ToInt32 key.[idx % key.Length]))
      |&gt; String.Concat
  
  [&lt;EntryPoint&gt;]
  let main argv = 
      let encrypted = encrypt &quot;IzzyDev&quot;
      printfn &quot;Encrypted: %s&quot; encrypted
      let decrypted = encrypt encrypted
      printfn &quot;Decrypted: %s&quot; decrypted
      0
  </code></pre>
  <p>How can i modify this code so that it encrypts a byte array instead of a string?</p>