package sihl

  1. Overview
  2. Docs
type t
val equal : t -> t -> bool

equal tkn1 tkn2 checks if two encrypted tokens tkn1 and tkn2 are equal.

val to_uri_safe_string : t -> string

to_uri_safe_string tkn turns an encrypted token tkn into a URI-safe base64 string. Used to make sure CSRF works with all encodings.

val of_uri_safe_string : string -> t option

of_uri_safe_string tkn turns a URI-safe string tkn into an encrypted token. Attempts to parse the base64 input tkn, which can fail. This does not perform any cryptographic operation to ensure tkn can be decrypted.

val to_struct : t -> Cstruct.t

to_struct tkn turns an encrypted token tkn to a raw format.

val from_struct : with_secret:Secret.t -> Cstruct.t -> t

from_struct ~with_secret tkn encrypts a raw token tkn using AES in ECB mode given a secret with_secret.

val from_struct_random : with_secret:Secret.t -> Cstruct.t -> t

from_struct_random ~with_secret tkn encrypts a raw token tkn. Additionally the encrypted result is scrambled with a random salt (IV) using AES in CBC mode given a secret with_secret.