WebPushEncryption.Encrypt (web_push_encryption v0.3.1) View Source

Module to encrypt notification payloads.

See the following links for details about the encryption process.

https://developers.google.com/web/updates/2016/03/web-push-encryption?hl=en

Link to this section Summary

Functions

Encrypts a web push notification body.

Link to this section Functions

Link to this function

encrypt(message, subscription, padding_length \\ 0)

View Source

Specs

encrypt(
  message :: binary(),
  subscription :: map(),
  padding_length :: non_neg_integer()
) :: map()

Encrypts a web push notification body.

Arguments

Return value

Returns the encrypted body as well as the necessary information in the following form:

%{ciphertext: ciphertext,               # the encrypted payload
  salt: salt,                           # the generated salt used during the encryption
  server_public_key: server_public_key} # the generated public key used during encryption