Created
October 8, 2019 12:17
-
-
Save tsif/10338d69fc85975783dc0259c50741ae 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 path = Bundle.main.path(forResource: "video", ofType: "mp4")! | |
let data = FileManager.default.contents(atPath: path)! | |
let key = SymmetricKey(size: .bits256) // key shared by both parties | |
let authentication = HMAC<SHA256>.authenticationCode(for: data, | |
using: key) | |
let authenticationData = Data(authentication) | |
// ~~~~~~ travel accross the network ~~~~~~~ | |
if (HMAC<SHA256>.isValidAuthenticationCode(authenticationData, | |
authenticating: data, | |
using: key)) { | |
print("Validated ✅") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment