Skip to content

Instantly share code, notes, and snippets.

@jeroen
Created December 7, 2016 14:02
Show Gist options
  • Save jeroen/1ffbfbdad40f4aad6657c337a4924f0e to your computer and use it in GitHub Desktop.
Save jeroen/1ffbfbdad40f4aad6657c337a4924f0e to your computer and use it in GitHub Desktop.
Encrypt using Github public key
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)
@jeroen
Copy link
Author

jeroen commented Dec 10, 2016

Note that you can use my_key() instead of read_key("~/.ssh/id_rsa").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment