Node.js
Node.js
Workaround for the deprecated Crypt2.SignString method
Shows how to replace the deprecated SignString method. (Chilkat is moving away from the use of CkByteData.)Chilkat Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
var success = false;
var crypt = new chilkat.Crypt2();
var cert = new chilkat.Cert();
// ...
// Load the cert from a source such as a .pfx/.p12 file, smart card, USB token, Apple keychain, Windows certificate store, etc.
//
success = crypt.SetSigningCert(cert);
// Sign the utf-8 byte representation of the text.
crypt.Charset = "utf-8";
var textToSign = "This is the text to sign";
// ------------------------------------------------------------------------
// The SignString method is deprecated:
outData = crypt.SignString(textToSign);
// ------------------------------------------------------------------------
// Workaround.
// (Chilkat is moving away from using CkByteData)
crypt.EncodingMode = "base64";
var base64_sig = crypt.SignStringENC(textToSign);
// If you want the binary bytes of the signature decoded from base64.
var bdSig = new chilkat.BinData();
bdSig.AppendEncoded(base64_sig,"base64");
}
chilkatExample();