Module termit

Serialize an Erlang term to signed encrypted binary and deserialize it back ensuring it's not been forged.

Description

Serialize an Erlang term to signed encrypted binary and deserialize it back ensuring it's not been forged.

Some code extracted from https://github.com/mochi/mochiweb/blob/master/src/mochiweb_session.erl.

Function Index

check_expired/1
decode/2Given a result of encode/2, i.e.
decode_base64/2
encode/2Serialize Term, encrypt and sign the result with Secret.
encode_base64/2
expires_by/2
expiring/2
issue_token/2
issue_token/3
verify_token/2

Function Details

check_expired/1

check_expired(Term) -> any()

decode/2

decode(Cipher::binary(), Secret::binary()) -> {ok, Term::any()} | {error, forged} | {error, badarg}

Given a result of encode/2, i.e. a signed encrypted binary, check the signature, uncrypt and deserialize into original term. -----------------------------------------------------------------------------

decode_base64/2

decode_base64(Bin, Secret) -> any()

encode/2

encode(Term::any(), Secret::binary()) -> Cipher::binary()

Serialize Term, encrypt and sign the result with Secret. Return binary(). -----------------------------------------------------------------------------

encode_base64/2

encode_base64(Term, Secret) -> any()

expires_by/2

expires_by(Term, When) -> any()

expiring/2

expiring(Term, Ttl) -> any()

issue_token/2

issue_token(Term::any(), Secret::binary()) -> Token::binary()

issue_token/3

issue_token(Term::any(), Secret::binary(), Ttl::non_neg_integer()) -> Token::binary()

verify_token/2

verify_token(Token::binary(), Secret::binary()) -> {ok, Term::any()} | {error, forged} | {error, badarg} | {error, expired}


Generated by EDoc