Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

C# UWP/WinRT Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text

HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(C# UWP/WinRT) Duplicate openssl dgst -sha256 -sign private.pem -out sha256.sig in.dat

Demonstrates how to duplicate this OpenSSL command:

openssl dgst -sha256 -sign private.pem -out sha256.sig in.dat
The in.dat file can contain text or binary data of any type. The OpenSSL command does the following:
  1. Creates a SHA256 digest of the contents of the input file
  2. Signs the SHA256 digest using the private key.

Chilkat Universal Windows Platform (UWP) / WinRT Downloads

Chilkat for the Universal Windows Platform (UWP)

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

Chilkat.PrivateKey pkey = new Chilkat.PrivateKey();

// Load the private key from an PEM file:
bool success = pkey.LoadPemFile("private.pem");
if (success != true) {
    Debug.WriteLine(pkey.LastErrorText);
    return;
}

Chilkat.Rsa rsa = new Chilkat.Rsa();

// Import the private key into the RSA component:
success = rsa.ImportPrivateKeyObj(pkey);
if (success != true) {
    Debug.WriteLine(rsa.LastErrorText);
    return;
}

// OpenSSL uses big-endian.
rsa.LittleEndian = false;

// Load the file to be signed.
Chilkat.BinData bdFileData = new Chilkat.BinData();
success = bdFileData.LoadFile("in.dat");

Chilkat.BinData bdSig = new Chilkat.BinData();
success = rsa.SignBd(bdFileData,"sha256",bdSig);
if (success != true) {
    Debug.WriteLine(rsa.LastErrorText);
    return;
}

// Save the binary signature to a file.
success = bdSig.WriteFile("signature.sig");
if (success != true) {
    Debug.WriteLine("Failed to write signature.sig.");
    return;
}

Debug.WriteLine("Success.");

 

© 2000-2019 Chilkat Software, Inc. All Rights Reserved.