Hi guys,
I try to make a test of encryption, decryption of a simple text.
I can crypt my text, but I can't decrypt it, do you see somewhere a dummy error of my part ?
Thanks for help
ClassMethod UnitTest()
{
set inputPlainText = "David"
// get private key
set privKeyFileName = "C:\temp\toto.pem"
set privobjCharFile = ##class(%Stream.FileCharacter).%New()
set privobjCharFile.Filename = privKeyFileName
set privKey = privobjCharFile.Read()
set Inputbase64 = $SYSTEM.Encryption.Base64Encode(inputPlainText)
// encrypte text using RSA
set encryptText = $System.Encryption.RSAEncrypt(Inputbase64, privKey)
// decrypt text using RSA
set outputbase64 = $System.Encryption.RSADecrypt(encryptText, privKey)
set plaintext = $SYSTEM.Encryption.Base64Decode(outputbase64)
return plaintext
}