sign

Apperyio.Crypto.sign(message, privateKey, algorithm)

Signs message with the specified algorithm using defined privateKey

Parameters

The method has the following parameters:

ParametersDescription
messageThe message that should be signed.
privateKeyPrivate key that should be used for signing message.
algorithmAlgorithm which should be used to sign the message. E.g. NONEwithRSA, MD2withRSA, MD5withRSA, SHA1withRSA, SHA256withRSA.
#Example
var PRIVATE_KEY = "-----BEGIN RSA PRIVATE KEY-----\n" +
    "MIIBOgIBAAJBAOd3oX3Jc5RFe/BVGuwAV8V+KOK81YYP/+H0EukEKBR5Ta6uVhuo\n" +
    "qW0OmAlU8eC3SvDmGDZDGDWIFwXGHLa0QX0CAwEAAQJASTnaeA3MJ8MXo395BeJR\n" +
    "4iO4UYrFziSvoc7yUI9FErx3R/rzP7v5SZCRs67BBwoAZNAa4UP7mF3BBguyTrLH\n" +
    "zQIhAP09HqiZc0Cv9uuKJOo1XDzG+SP2eVCcqLXQd2/NSfRzAiEA6f29OYhkV3IP\n" +
    "Bv0ArlaHOq29sRldVWdLDqF/0GGUZk8CIEJVk0VYxM7qCQUT762GAr5M5JAeDRMn\n" +
    "pi3SCKc5oCivAiB1diX+cqSEbUJz7J/h5Jf/8eXOuH/s9mxsTNA/yCxZ6wIhALRx\n" +
    "e+a2o02ADXyYBT17liomKb3Db31Cjrwqms1mTTd8\n" +
    "-----END RSA PRIVATE KEY-----\n";
var message = "testMessage";
var signed = Apperyio.Crypto.sign(message, PRIVATE_KEY, "SHA1withRSA");
Apperyio.response.success({
    signed: signed
}, "application/json");
{
	"signed": "yt9IVwQjwlk4VkFvROUR7fM7kzKdRvIH2L/15Eh3YcszPVTxguy+d3qVbDO6ZuEX3xNgy+SRsLO5FOMYAIXnCQ=="
}