Go
Go
RSA Import Public Key from Certificate PEM
See more RSA Examples
Uses a certificate's public key for RSA encryption. The public key from the certificate .pem file is used.Chilkat Go Downloads
success := false
cert := chilkat.NewCert()
success = cert.LoadFromFile("qa_data/pem/mf_public_rsa.pem")
if success == false {
fmt.Println(cert.LastErrorText())
cert.DisposeCert()
return
}
pubKey := chilkat.NewPublicKey()
cert.GetPublicKey(pubKey)
rsa := chilkat.NewRsa()
rsa.UsePublicKey(pubKey)
rsa.SetEncodingMode("base64")
encryptedStr := rsa.EncryptStringENC("hello",false)
fmt.Println("encrypted string = ", *encryptedStr)
cert.DisposeCert()
pubKey.DisposePublicKey()
rsa.DisposeRsa()