verify

Apperyio.Crypto.verify(message, publicKey, signature, algorithm)

Verifies message with the specified algorithm using defined publicKey and signature

#Parameters The method has the following parameters:

Parameters Description

message

Message that should be verified.

publicKey

Public key that should be used for verifying message.

signature

Message that was signed with private key.

algorithm

Algorithm of signing message. E.g. NONEwithRSA, MD2withRSA, MD5withRSA, SHA1withRSA, SHA256withRSA.

#Example

var SIGNED = "yt9IVwQjwlk4VkFvROUR7fM7kzKdRvIH2L/15Eh3YcszPVTxguy+d3qVbDO6ZuEX3xNgy+SRsLO5FOMYAIXnCQ==";
var PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\\n" +
    "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAOd3oX3Jc5RFe/BVGuwAV8V+KOK81YYP\\n" +
    "/+H0EukEKBR5Ta6uVhuoqW0OmAlU8eC3SvDmGDZDGDWIFwXGHLa0QX0CAwEAAQ==\\n" +
    "-----END PUBLIC KEY-----\\n";
var FALSE_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\\n" +
    "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALF4gq5fAbKqMYI+7I1krrCHys/PkBcs\\n" +
    "FqF+wXd46JJeFDvEG18kr9pxYNeuGe4ZLjPyz/Y+D9hyP8OGXzgIoGsCAwEAAQ==\\n" +
    "-----END PUBLIC KEY-----\\n";
var message = "testMessage";
true_res = Apperyio.Crypto.verify(message, PUBLIC_KEY, SIGNED, "SHA1withRSA");
false_res = Apperyio.Crypto.verify(message, FALSE_PUBLIC_KEY, SIGNED, "SHA1withRSA");
Apperyio.response.success({
    true_res: true_res,
    false_res: false_res
}, "application/json");
{
	"false_res": false,
	"true_res": true
}