Last active
August 29, 2015 14:15
-
-
Save jeksys/b9b1ef7b21fd434eb322 to your computer and use it in GitHub Desktop.
xorcrypto
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let text = [UInt8]("hello!!!".utf8) | |
let cipher = [UInt8]("good".utf8) | |
var encrypted = [UInt8]() | |
// encrypt bytes | |
for t in enumerate(text) { | |
encrypted.append(t.element ^ cipher[t.index%cipher.count]) | |
} | |
println(encrypted) | |
var decrypted = [UInt8]() | |
// decrypt bytes | |
for t in enumerate(encrypted) { | |
decrypted.append(t.element ^ cipher[t.index%cipher.count]) | |
} | |
String(bytes: decrypted, encoding: NSUTF8StringEncoding) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment