Cryptography

Updated: 06 August 2022

Public key cryptography

Alternatively asymmetric cryptography, is a system in which the keys come in pairs. The transformation performed by one key can only be undone with the other key. One key is kept private while the other is made public.

Typically much slower than symmetric algorithms and the size of message they can encrypt is proportional to the size of the key, so they do not scale well for long messages. As a result, it’s common for an encryption system to use a symmetric algorithm to encrypt the message, then a public-key system to encrypt the symmetric key. This arrangement can confer the benefits of both systems.

Commonly used public-key cryptosystems are RSA (for both signing and encryption), DSA (for signing) and Diffie-Hellman (for key agreement).

Digital signatures

Private key used to sign and public key used to verify.

Encryption

Public key used to encrypt, private key used to decrypt. Therefore anyone could encrypt a message to the owner of the private key, but only the owner of the private key could decrypt it.

See MDN

gpg

Updated: 27 October 2021

Encrypt and decrypt a file with one password. Without --no-symkey-cache the password is cached on the system.

gpg --no-symkey-cache --symmetric --cipher-algo AES256 notes.txt
gpg --output notes.txt --decrypt notes.txt.gpg