Skip to content

Instantly share code, notes, and snippets.

View myoffe's full-sized avatar
🏠
Working from home

Michael Yoffe myoffe

🏠
Working from home
View GitHub Profile

1. Converts the recipient's public key to PKCS8

ssh-keygen -f id_rsa.pub -e -m PKCS8 > id_rsa.pkcs8.pubkey

One way to obtain a recipient's public key is from GitHub, by adding .keys to their profile url, e.g. https://github.com/noamnelke.keys

2. Encrypt a string

This pipes a secret string into openssl, encrypts it with the recipient's public key and pipes the result to openssl again to transcode it into base64 (without the last step it would be binary, which is fine for a file, but harder to paste somewhere).