Last active
October 8, 2019 14:51
-
-
Save tsif/3c95187501639553bdefa3b53bf0fe3e to your computer and use it in GitHub Desktop.
This file contains 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 key = SymmetricKey(size: .bits256) | |
let path = Bundle.main.path(forResource: "video", ofType: "mp4")! | |
let data = FileManager.default.contents(atPath: path)! | |
// To encrypt | |
let encryptedData = try! ChaChaPoly.seal(data, using: key) | |
// To decrypt | |
let sealedBox = try! ChaChaPoly.SealedBox(combined: encryptedData) | |
let decryptedData = try! ChaChaPoly.open(sealedBox, using: key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment