let xor_cipher key text =
  let n = String.length text in
  let kn = String.length key in
  let buf = Buffer.create n in
  for i = 0 to n - 1 do
    let c = Char.code text.[i] in
    let k = Char.code key.[i mod kn] in
    Buffer.add_string buf (String.make 1 (Char.chr (c lxor k)))
  done;
  Buffer.contents buf

;;

let encoded = xor_cipher "key" "Hello!" in
let decoded = xor_cipher "key" encoded in
String.length decoded * 100 + (if decoded = "Hello!" then 1 else 0)
