-- cycleKey makes use of the cycle function of Data.ByteString.Lazy
-- it takes a ByteString and creates a new infinite ByteString out of it
-- cycling the key indefinately. Since it is a lazy ByteString, we only use
-- it as far as needed, which is the length of the incoming ByteString (bs)
-- So these two are XORred against eachother, just like the fixedXor function
-- does for two ByteStrings of the same length.
cycleKey :: B.ByteString -> B.ByteString -> B.ByteString
cycleKey bs key =
  let
    cycledKey =
      BL.fromStrict key
      |>BL.cycle

  in
    BL.zipWith BB.xor cycledKey (BL.fromStrict bs)
    |> BL.pack
    |> BL.toStrict
cycleKey :: B.ByteString -> B.ByteString -> B.ByteString
cycleKey bs key =
  let
    cycledKey =
      BL.fromStrict key
      |>BL.cycle

  in
    BL.zipWith BB.xor cycledKey (BL.fromStrict bs)
    |> BL.pack
    |> BL.toStrict
cycleKey bs key =
  let
    cycledKey =
      BL.fromStrict key
      |>BL.cycle

  in
    BL.zipWith BB.xor cycledKey (BL.fromStrict bs)
    |> BL.pack
    |> BL.toStrict