class

Crypt::Signer

Inherits Reference / Object

Sign and verify given data.

Constants

INVALID_SIGN = "Not valid"
SIGN_SEP = "__--"

Constructors

new(secret : String, digest : Symbol = :sha1)

Create a Signer instance.

Source

Class methods

parse_data_and_digest(signed_data) : Tuple(String, String)
Source

Instance methods

sign(value : String | Bytes) : String

Generates signed data. Returns an URL and filename safe alphabet (RFC 4648).

Source
valid?(data, digest) : Bool

Compare data and digest.

Source
verify(signed_data, error_message = INVALID_SIGN) : String

Verify and decode. error_message allows to customize the error message when the signature is not valid.

Source
verify_and_decode(signed_data : String) : String | Nil

Verify and decode.

It is recommended to use verify which has a more precise return (returns String or raises a SignatureError).

Source
verify_raw(signed_data : String, error_message = INVALID_SIGN) : Bytes

Verify and decode. error_message allows to customize the error message when the signature is not valid.

This method can produce a different error message than error_message.

Source
verify_raw(signed_data : Bytes, error_message = INVALID_SIGN) : Bytes

Verify and decode. error_message allows to customize the error message when the signature is not valid.

This method can produce a different error message than error_message.

Source