INNER CODE UNIT · Swift
tag
jedisct1/swift-sodium · Sources/Sodium/Auth.swift:18
func tag(message: Bytes, secretKey: SecretKey) -> Bytes? {
guard secretKey.count == KeyBytes else { return nil }
var tag = [UInt8](count: Bytes)
guard crypto_auth(
&tag,
message, UInt64(message.count),
secretKey
).exitCode == .SUCCESS else { return nil }
return tag
}
/**
Verifies that an authentication tag is valid for a message and a key
- Parameter message: The message to verify.
- Parameter secretKey: The key required to create and verify messages.