Created
October 17, 2018 14:26
-
-
Save mlaster/c3d00afd71839abfb4de62874c4d017d to your computer and use it in GitHub Desktop.
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
extension Data { | |
func encrypt(key: Data) { | |
let ivData = Data.randomBytes(count: kCCKeySizeAES128) | |
var tag = Data(count: kCCKeySizeAES128) | |
var cipherText = Data(count: count) | |
_ = cipherText.withUnsafeMutableBytes { (cipherPtr) in | |
_ = tag.withUnsafeMutableBytes { (tagPtr) in | |
_ = ivData.withUnsafeBytes { (ivPtr) in | |
_ = key.withUnsafeBytes { (keyPtr) in | |
_ = keyPtr | |
_ = ivPtr | |
_ = tagPtr | |
_ = cipherPtr | |
// Do crypto stuff here | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get a compile error on line 12: 'inout Data' is not convertible to 'Data'