Skip to content

[API] Encrypting a secret using the public key and libsodium #26535

Answered by pat-s
pat-s asked this question in Actions
Discussion options

You must be logged in to vote

Thanks @dannyben!

Your post helped, thanks! I got it working now and I think I was already very close yesterday but did some mistakes on the public key side - but I can’t really recall.

In the end, my solution looks like this. Here, we assume that the Github public key is already available via some external code.

library("sodium")
library("base64enc")

convert to raw for sodium

msg = "message"
msg_raw <- charToRaw(msg)

decode public key

pub_key_gh_dec <- base64enc::base64decode(pub_key_gh)

encrypt using the pub key

msg_raw_encr <- sodium::simple_encrypt(msg_raw, pub_key_gh_dec)

base64 encode secret

msg_raw_encr_enc <- base64enc::base64encode(msg_raw_encr)

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants