Guides

Each guide explains how to accomplish a common task, with the recommended algorithm and complete code that you can copy. The alternatives, and when to prefer them, come at the end.

I want to…

Recommended

Guide

Encrypt data with a secret key

AES-GCM

Encrypt data with a secret key

Encrypt data with a password

scrypt + AES-GCM

Work with passwords

Store and check users’ passwords

bcrypt

Work with passwords

Encrypt data for a recipient’s public key

HPKE

Encrypt data for a recipient’s public key

Sign data, or verify a signature

Ed25519

Sign data and verify signatures

Compute a hash of data or of a file

SHA-256

Hash data and authenticate messages

Authenticate a message with a secret key (MAC)

HMAC-SHA256

Hash data and authenticate messages

Generate, save, and load keys

PEM files (PKCS#8)

Generate, save, and load keys

Agree on a secret key with another party

ECDH (P-256) + HKDF

Generate, save, and load keys