Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) RSA Signature using Private Key from .snk FileSee more RSA ExamplesA .snk file (Strong Name Key file) is a file format used in the .NET ecosystem to store an RSA public/private key pair. This key pair is typically used for strong-naming assemblies, which is a process of signing .NET assemblies to ensure their integrity and to uniquely identify them. This example loads a private key from a .snk file and creates an RSA signature.
integer li_rc oleobject loo_Rsa string ls_XmlStr integer li_Success string ls_SigBase64 loo_Rsa = create oleobject // Use "Chilkat_9_5_0.Rsa" for versions of Chilkat < 10.0.0 li_rc = loo_Rsa.ConnectToNewObject("Chilkat.Rsa") if li_rc < 0 then destroy loo_Rsa MessageBox("Error","Connecting to COM object failed") return end if // Load the .snk and return the private key as XML. ls_XmlStr = loo_Rsa.SnkToXml("./test.snk") if loo_Rsa.LastMethodSuccess = 0 then Write-Debug loo_Rsa.LastErrorText destroy loo_Rsa return end if li_Success = loo_Rsa.ImportPrivateKey(ls_XmlStr) if li_Success = 0 then Write-Debug loo_Rsa.LastErrorText destroy loo_Rsa return end if // Sign the SHA-256 hash of the utf-8 byte representation of the contents of sb // Return the signature in base64 format. loo_Rsa.EncodingMode = "base64" loo_Rsa.Charset = "utf-8" ls_SigBase64 = loo_Rsa.SignStringENC("This is the text to be hashed and signed.","sha256") if loo_Rsa.LastMethodSuccess = 0 then Write-Debug loo_Rsa.LastErrorText destroy loo_Rsa return end if Write-Debug "RSA signature as base64: " + ls_SigBase64 destroy loo_Rsa |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.