On Mac:
https://docs.docker.com/desktop/setup/install/mac-install/
On Windows:
https://docs.docker.com/desktop/setup/install/windows-install/
Open the Terminal (Terminal
) app and run:
docker run -it debian
It is recommended that you install the Terminal app for Windows available at:
https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701
Open the Terminal (Terminal
) app and run:
docker run -it debian
Install the cryptographic library OpenSSL:
apt-get update && apt-get install -y openssl
Encrypt and decrypt a plaintext message with symetric key cryptography.
Create a file with a message:
echo Attack at 5:00 > message.txt
Read the file with a message:
cat message.txt
Encrypt the message:
openssl enc -AES-256-CBC -base64 -pbkdf2 -in message.txt -out encrypted.txt -p -pass pass:password
Show the encrypted ciphertext:
cat encrypted.txt
Decrypt the ciphertext:
openssl enc -AES-256-CBC -base64 -pbkdf2 -in encrypted.txt -out decrypted.txt -p -pass pass:password -d
Show the decrypted message:
cat decrypted.txt
Encrypt and decrypt a plaintext message using the RSA (Rivest–Shamir–Adleman) public / private key cryptography.
Create a file with a message:
echo Retreat at 6:00 > message.txt
Read the file with a message:
cat message.txt
Create a private key:
openssl genpkey -algorithm RSA -out private.txt
View the created private key:
cat private.txt
Derive a public key:
openssl rsa -pubout -in private.txt -out public.txt
View the created public key:
cat public.txt
Encrypt the message using the public key:
openssl pkeyutl -encrypt -pubin -inkey public.txt -in message.txt -out encrypted.bin
Show the encrypted ciphertext:
base64 encrypted.bin
Decrypt the ciphertext using the private key:
openssl pkeyutl -decrypt -inkey private.txt -in encrypted.bin -out decrypted.txt
Show the decrypted message:
cat decrypted.txt
Sign and verify a plaintext message using EC (Elliptic-curve) public / private key cryptography.
Create a file with a message:
echo Send 1 million USD to John Smith > message.txt
Read the file with a message:
cat message.txt
Create a private key:
openssl ecparam -name secp256k1 -genkey -noout -out private.txt
View the created private key:
cat private.txt
Derive a public key:
openssl ec -pubout -in private.txt -out public.txt
View the created public key:
cat public.txt
Sign the message using the private key:
openssl dgst -sha256 -sign private.txt -out signature.bin message.txt
Show the message signature:
base64 signature.bin
Verify the signature using the public key:
openssl dgst -sha256 -verify public.txt -signature signature.bin message.txt
Alter the message:
echo Send 2 million USD to John Smith > message.txt
Verify the signature using the public key:
openssl dgst -sha256 -verify public.txt -signature signature.bin message.txt