Can i do something like openssl_private_encrypt of php in go

I’m trying to migrate my projects from php to go but I found there is no private key encryption method.
As far as I know, go only support private key decryption (rsa.DecryptOAEP).
But php has one called openssl_private_encrypt PHP: openssl_private_encrypt - Manual
Is there any replacement that I can use?

The PHP: openssl_private_encrypt - Manual is one of the part Cryptography Extensions. Which is official lib cryptography for PHP global used.

In Golang, There is 2 options to get your functions for encrypt-decrypt with openssl private:

  • Options 1: Build your own encrypt-decrypt func. Golang has official packages for cryptography. You can see example of encrypt-decrypt in here.
  • Options 2: Use golang community package. There is a lot lib out there to encrypt-decrypt. For example:

Try to comparing each others, and find out that suitable for you.
Hope this could help your questions @orzorc. :blush:

1 Like