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

VBScript Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
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

 

 

 

(VBScript) Generate ECDSA Key and Get Details as XML

Demonstrates how to generate an ECC key and gets the parts as XML.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("output.txt", True)

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

set ecc = CreateObject("Chilkat_9_5_0.Ecc")

'  Generate a random ECC private key on the secp256k1 curve.
'  Chilkat also supports other curves, such as secp384r1, secp521r1, and secp256r1.

'  Create a Fortuna PRNG and seed it with system entropy.
'  This will be our source of random data for generating the ECC private key.
set fortuna = CreateObject("Chilkat_9_5_0.Prng")
entropy = fortuna.GetEntropy(32,"base64")
success = fortuna.AddEntropy(entropy,"base64")

' privKey is a Chilkat_9_5_0.PrivateKey
Set privKey = ecc.GenEccKey("secp256k1",fortuna)
If (ecc.LastMethodSuccess <> 1) Then
    outFile.WriteLine(ecc.LastErrorText)
    WScript.Quit
End If

'  An EC private key has this ASN.1
'  ECPrivateKey ::= SEQUENCE {
'      version        INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1),
'      privateKey     OCTET STRING,
'      parameters [0] ECParameters {{ NamedCurve }} OPTIONAL,
'      publicKey  [1] BIT STRING OPTIONAL (This is the ANSI X9.63 public key format.)

set asn = CreateObject("Chilkat_9_5_0.Asn")
success = asn.LoadEncoded(privKey.GetPkcs1ENC("base64"),"base64")
If (success <> 1) Then
    outFile.WriteLine(asn.LastErrorText)
    WScript.Quit
End If

set xml = CreateObject("Chilkat_9_5_0.Xml")
success = xml.LoadXml(asn.AsnToXml())

outFile.WriteLine(xml.GetXml())

'  The XML looks like this:
'  <?xml version="1.0" encoding="utf-8" ?>
'  <sequence>
'      <int>01</int>
'      <octets>JgJvBG+3wletkJab8iXAkpz0O8/AgWZSpkYVcB7SpnU=</octets>
'      <contextSpecific tag="0" constructed="1">
'          <oid>1.3.132.0.10</oid>
'      </contextSpecific>
'  </sequence>

'  The 32-byte private key is in the octets..
'  Get it as hex.
set crypt = CreateObject("Chilkat_9_5_0.Crypt2")
privKeyHex = crypt.ReEncode(xml.GetChildContent("octets"),"base64","hex")

outFile.WriteLine("EC private key as hex = " & privKeyHex)


outFile.Close

 

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