(PureBasic) RSA Import Public Key
Shows how to select/import a public key for RSA encryption or signature verification.
IncludeFile "CkPublicKey.pb"
IncludeFile "CkRsa.pb"
Procedure ChilkatExample()
pubKey.i = CkPublicKey::ckCreate()
If pubKey.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; In all Chilkat methods expecting a path, you pass either absolute or relative paths.
success.i = CkPublicKey::ckLoadFromFile(pubKey,"rsaKeys/myTestRsaPublic.pem")
If success = 0
Debug CkPublicKey::ckLastErrorText(pubKey)
CkPublicKey::ckDispose(pubKey)
ProcedureReturn
EndIf
rsa.i = CkRsa::ckCreate()
If rsa.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Tell RSA to use the public key.
CkRsa::ckImportPublicKeyObj(rsa,pubKey)
CkPublicKey::ckDispose(pubKey)
CkRsa::ckDispose(rsa)
ProcedureReturn
EndProcedure
|