Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Go Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
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
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(Go) SHA3 Hash to Match Test Vectors

This example demonstrates SHA3 hashing to match some results published by other implementations.

Note: This example requires Chilkat v9.5.0.83 or greater.

Chilkat Go Downloads

Go Package for Windows, MacOS, Linux, Alpine Linux, Solaris

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

    // This example requires Chilkat v9.5.0.83 or greater.
    crypt := chilkat.NewCrypt2()
    crypt.SetEncodingMode("hexlower")

    // Input message: "abc", hashing the bytes 0x616263
    // SHA-3-224:	e642824c3f8cf24a d09234ee7d3c766f c9a3a5168d0c94ad 73b46fdf
    // SHA-3-256:	3a985da74fe225b2 045c172d6bd390bd 855f086e3e9d525b 46bfe24511431532
    // SHA-3-384:	ec01498288516fc9 26459f58e2c6ad8d f9b473cb0fc08c25 96da7cf0e49be4b2 98d88cea927ac7f5 39f1edf228376d25
    // SHA-3-512"	b751850b1a57168a 5693cd924b6b096e 08f621827444f70d 884f5d0240d2712e 10e116e9192af3c9 1a7ec57647e39340 57340b4cf408d5a5 6592f8274eec53f0

    msg := "abc"
    fmt.Println("---- abc ----")
    crypt.SetHashAlgorithm("sha3-224")
    fmt.Println(*crypt.HashStringENC(msg))
    crypt.SetHashAlgorithm("sha3-256")
    fmt.Println(*crypt.HashStringENC(msg))
    crypt.SetHashAlgorithm("sha3-384")
    fmt.Println(*crypt.HashStringENC(msg))
    crypt.SetHashAlgorithm("sha3-512")
    fmt.Println(*crypt.HashStringENC(msg))

    // Input Message: "", hashing 0 bytes.
    // SHA-3-224	6b4e03423667dbb7 3b6e15454f0eb1ab d4597f9a1b078e3f 5b5a6bc7
    // SHA-3-256	a7ffc6f8bf1ed766 51c14756a061d662 f580ff4de43b49fa 82d80a4b80f8434a
    // SHA-3-384	0c63a75b845e4f7d 01107d852e4c2485 c51a50aaaa94fc61 995e71bbee983a2a c3713831264adb47 fb6bd1e058d5f004
    // SHA-3-512	a69f73cca23a9ac5 c8b567dc185a756e 97c982164fe25859 e0d1dcc1475c80a6 15b2123af1f5f94c 11e3e9402c3ac558 f500199d95b6d3e3 01758586281dcd26

    msg = ""
    fmt.Println("---- nothing ----")
    crypt.SetHashAlgorithm("sha3-224")
    fmt.Println(*crypt.HashStringENC(msg))
    crypt.SetHashAlgorithm("sha3-256")
    fmt.Println(*crypt.HashStringENC(msg))
    crypt.SetHashAlgorithm("sha3-384")
    fmt.Println(*crypt.HashStringENC(msg))
    crypt.SetHashAlgorithm("sha3-512")
    fmt.Println(*crypt.HashStringENC(msg))

    // Input message: "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
    // SHA-3-224	543e6868e1666c1a 643630df77367ae5 a62a85070a51c14c bf665cbc
    // SHA-3-256	916f6061fe879741 ca6469b43971dfdb 28b1a32dc36cb325 4e812be27aad1d18
    // SHA-3-384	79407d3b5916b59c 3e30b09822974791 c313fb9ecc849e40 6f23592d04f625dc 8c709b98b43b3852 b337216179aa7fc7
    // SHA-3-512	afebb2ef542e6579 c50cad06d2e578f9 f8dd6881d7dc824d 26360feebf18a4fa 73e3261122948efc fd492e74e82e2189 ed0fb440d187f382 270cb455f21dd185

    fmt.Println("---- abcdefg... ----")
    msg = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
    crypt.SetHashAlgorithm("sha3-224")
    fmt.Println(*crypt.HashStringENC(msg))
    crypt.SetHashAlgorithm("sha3-256")
    fmt.Println(*crypt.HashStringENC(msg))
    crypt.SetHashAlgorithm("sha3-384")
    fmt.Println(*crypt.HashStringENC(msg))
    crypt.SetHashAlgorithm("sha3-512")
    fmt.Println(*crypt.HashStringENC(msg))

    crypt.DisposeCrypt2()

 

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