Skip to main content
Version: 7.2402.x.x RR

Verifier object methods

Each parameter is interpeted as an ASCII string (1 byte per character), but isn't limited to ASCII characters.

For non-ASCII values, use \x01 - \xFF, but note that the parameters cannot contain \x00. If there is a \x00 character in any parameter, then the verifier ignores that character along with the part that follows it.

Because of this, binary inputs should be Base64 encoded first.

MethodDescriptionSample
verifier:sign(data)This method returns the given data followed by the hashed value (separated by an underscore).local signedValue = verifier:sign("TheTextToSign")
verifier:verify(signedValue)This method expects a value signed with the verifier's method "sign". If the signature matches, the method will return the data (without the signature). If the signature does not match, the method returns nil.local verifiedData = verifier:verify(signedValue)
verifier:createTag(data)This method returns the signature (tag) for the given data. The tag can be used to verify a given value via the method verifier:verifyTag().
verifier:verifyTag(data, tag)This methods returns - "true", if the data matches the given tag, and - "false", if it does not match.local result = verifier:verifyTag("TheText", tag)

Example

local verifier = nevis.crypto.verifier.new("TheKey")
local signedMsg = verifier:sign("TheTextToSign")) # signedText is TheTextToSign_signatureTag
local verifiedValue = verifier:verify(signedText)
if verifiedValue then
# verifiedValue is "TheTextToSign"
else
# verifying failed
end
local tagText = verifier:createTag("TheTextToTag")) # tagText is HrRoBMhhxjCaJMOnGfMoeaUSGOruiWiwGdwKQtsUOfALKF
local tVerifiedValue = verifier:verifyTag("TheTextToTag", tagText)
if tVerifiedValue then
# tVerifiedValue is "TheTextToTag"
else
# verifying failed
end