Ruby
Ruby
Workaround for the deprecated Crypt2.VerifyString method
Shows how to replace the deprecated VerifyString method. (Chilkat is moving away from the use of CkByteData.)Chilkat Ruby Downloads
require 'chilkat'
crypt = Chilkat::CkCrypt2.new()
# Specifies how the original data bytes are converted to characters
crypt.put_Charset("utf-8")
originalText = "this is the string that was signed."
sigPath = "c:/someDir/example.p7s"
# ------------------------------------------------------------------------
# The OpaqueVerifyString method is deprecated:
detachedSigBytes = Chilkat::CkByteData.new()
detachedSigBytes.loadFile(sigPath)
verified = crypt.VerifyString(originalText,detachedSigBytes)
# ------------------------------------------------------------------------
# Workaround.
# (Chilkat is moving away from using CkByteData)
bdSig = Chilkat::CkBinData.new()
bdSig.LoadFile(sigPath)
encoding = "base64"
crypt.put_EncodingMode(encoding)
verified = crypt.VerifyStringENC(originalText,bdSig.getEncoded(encoding))