Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func decode(input: String, key: String) -> String {
- let inputBytes = input.utf8
- let keyBytes = key.utf8
- var keyIndex = 0
- var inputArray = [UInt8] (inputBytes)
- var keyArray = [UInt8] (keyBytes)
- for i in 0..<inputArray.count {
- print("input \(i) = \(inputArray[i])")
- print("key \(i) = \(keyArray[keyIndex])")
- inputArray[i] = inputArray[i] ^ keyArray[keyIndex]
- keyIndex = keyIndex + 1
- if (keyIndex == keyArray.count) {
- keyIndex = 0
- }
- }
- return String(bytes: inputArray, encoding: String.Encoding.utf8)!
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement