lazysodium-java icon indicating copy to clipboard operation
lazysodium-java copied to clipboard

help using sealed box for GitHub secret

Open JonGilmore opened this issue 2 years ago • 1 comments

I'm trying to use this to encrypt a GitHub secret (reference) using sealed boxes, but am getting 500's back from the enterprise github server when I actually make the HTTP PUT call. Here's my function that I'm using to encrypt:

  fun encryptSecret(secret: String): String {
    val pub = "MyGhPubKeyThatIveRemoved"
    return Base64.getEncoder().encodeToString(
      LazySodiumJava(SodiumJava(), StandardCharsets.UTF_8).cryptoBoxSealEasy(
        secret, Key.fromPlainString(pub)
      ).toByteArray()
    )

I'm not actually sure if I'm encrypting wrong, or if there's another issue with my code, the 500 that I get back from GitHub doesn't seem too helpful so far. FYI, this function is largely derived from here.

JonGilmore avatar Jan 16 '23 03:01 JonGilmore

Old issue, but I found this article that was really helpful to get it working for me. In my case, I was encoding strings in the wrong way.

https://philiplimbeck.dev/2021/02/19/github-secrets-java.html

Martijnpold avatar Apr 24 '23 00:04 Martijnpold