Last active
January 14, 2016 14:01
-
-
Save jeroen/57d1304f9e40f4577cd4 to your computer and use it in GitHub Desktop.
Encrypt with github key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Send Gabor an encrypted message | |
library(openssl) | |
library(jsonlite) | |
# Get Gabor's pubkey | |
keydata <- fromJSON("https://api.github.com/users/gaborcsardi/keys") | |
cat("Number of keys:", nrow(keydata), "\n") | |
pubkey <- read_pubkey(textConnection(keydata$key[1])) | |
print(pubkey) | |
# Encrypt a short secret | |
mysecret <- charToRaw("This is a secret") | |
msg <- base64_encode(rsa_encrypt(mysecret, pubkey)) | |
# Gabor has the corresponding private key: | |
key <- read_key("~/.ssh/id_rsa") | |
rawToChar(rsa_decrypt(base64_decode(msg), key)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment