Created
December 7, 2016 14:02
-
-
Save jeroen/1ffbfbdad40f4aad6657c337a4924f0e to your computer and use it in GitHub Desktop.
Encrypt using Github public 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
github_pubkey <- function(user){ | |
url <- sprintf("https://api.github.com/users/%s/keys", user) | |
keys <- jsonlite::fromJSON(url) | |
lapply(keys$key, openssl::read_pubkey) | |
} | |
# Get pubkey from Gabor | |
gabor <- github_pubkey('gaborcsardi') | |
pubkey <- gabor[[1]] #has 3 keys, use first one | |
# Example of old repo | |
buf <- openssl::rsa_encrypt(charToRaw("My secret token"), pubkey) | |
openssl::base64_encode(buf) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that you can use
my_key()
instead ofread_key("~/.ssh/id_rsa")
.