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

PowerBuilder Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
Mastercard

MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(PowerBuilder) Hungary NAV Invoicing Signature Calculation

Demonstrates the requestSignature calculation for the Hungarian NAV Online Invoicing System REST API v2.0.

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

For more information, see https://onlineszamla.nav.gov.hu/api/files/container/download/Online%20Szamla_Interfesz%20specifik%C3%A1ci%C3%B3_EN_v2.0.pdf

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

integer li_rc
integer li_Success
oleobject loo_Crypt
string ls_RequestId
string ls_Timestamp
string ls_SignatureKey
oleobject loo_SbFinalHashBase
integer li_NumReplaced
string ls_InvoiceOperation
string ls_InvoiceData
oleobject loo_SbHashBase
string ls_FirstHash
string ls_SecondHash
string ls_RequestSignature

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

// This example performs the following calculation:

// 1.5.1 Calculations for manageInvoice and manageAnnulment operations
// 
// For the manageInvoice and manageAnnulment operations comprising the core of requestSignature, 
// requestSignature is calculated using partial authentication, concatenating the hash values for 
// indices 1-100 as well as additional SHA3-512 hash operations. The partial authentication can be 
// derived by concatenating the following values:
// 
//   - requestId value
//   - UTC timestamp tag value using a YYYYMMDDhhmmss mask
//   - string literal of the technical users signature key
// 
// When concatenating, the date and time separators as well as the time zone must be removed for timestamp masking.
// 
// The index hash value can be derived from the uppercase SHA3-512 hash values following the concatenation of the 
// operation and base64 content for the individual indices:
// 
//   - literal value of invoiceOperation or annulmentOperation
//   - base64 content in the invoiceData or invoiceAnnulment tag
// 
// The calculated hash values should be appended after the partial hash, in the order corresponding to the indices. 
// The SHA3-512 hash result (capitals) of the string thus concatenated yields the requestSignature value.
// 
// A fictitious example for request data:
// 
// 	- requestId = TSTKFT1222564
// 	- timestamp = 2017-12-30T18:25:45.000Z
// 	- technical users signature key = ce-8f5e-215119fa7dd621DLMRHRLH2S
// 	- the index#1 invoice data items
// 	- invoiceOperation = CREATE
// 	- invoiceData = QWJjZDEyMzQ=
// 	- the index#2 invoice data items
// 	- invoiceOperation = MODIFY
// 	- invoiceData = RGNiYTQzMjE=
// 	- partial authentication value = TSTKFT122256420171230182545ce-8f5e-215119fa7dd621DLMRHRLH2S
// 	- the first index hash =
// 		- hash base = CREATEQWJjZDEyMzQ=
// 		- lowercase hash = 4317798460962869bc67f07c48ea7e4a3afa301513ceb87b8eb94ecf92bc220a89c480f87f0860e85e29a3b6c0463d4f29712c5ad48104a6486ce839dc2f24cb
// 		- uppercase hash = 4317798460962869BC67F07C48EA7E4A3AFA301513CEB87B8EB94ECF92BC220A89C480F87F0860E85E29A3B6C0463D4F29712C5AD48104A6486CE839DC2F24CB
// 	- the second index hash =
// 		- hash base = MODIFYRGNiYTQzMjE=
// 		- lowercase hash = a881218238933f6ffb9e167445cb4daa9749bcf484fde48ab7649fd25e8b634a4736a65a7c4a8e2831119f739837e006566f97370415aad55e268605206f2a6c
// 		- uppercase hash = A881218238933F6FFB9E167445CB4DAA9749BCF484FDE48AB7649FD25E8B634A4736A65A7C4A8E2831119F739837E006566F97370415AAD55E268605206F2A6C
// 
// Thus, the base for the entire requestSignature is:
// 	TSTKFT122256420171230182545ce-8f5e-215119fa7dd621DLMRHRLH2S4317798460962869BC67F07C48EA7E4A3AFA301513CEB87B8EB94ECF92BC220A89C480F87F0860E85E29A3B6C0463D4F29712C5AD48104A6486CE839DC2F24CBA881218238933F6FFB9E167445CB4DAA9749BCF484FDE48AB7649FD25E8B634A4736A65A7C4A8E2831119F739837E006566F97370415AAD55E268605206F2A6C
// 
// Value of requestSignature after SHA3-512 hashing and converting to uppercase:
// 	60BC80609EE3B8F42FE904200A49A1921A1DADA08D55319ACD40C59F626514B74EEA49011D372600A10DBCF8199D590DA9C2841D987308F2D83DAE17C2470C42
// 
// -------------------

loo_Crypt = create oleobject
li_rc = loo_Crypt.ConnectToNewObject("Chilkat_9_5_0.Crypt2")
if li_rc < 0 then
    destroy loo_Crypt
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// IMPORTANT: This example requires Chilkat v9.5.0.83 or greater.  The SHA3 hash algorithm is implemented in Chilkat v9.5.0.83, but not in earlier versions.
// IMPORTANT: This example requires Chilkat v9.5.0.83 or greater.  The SHA3 hash algorithm is implemented in Chilkat v9.5.0.83, but not in earlier versions.
// IMPORTANT: This example requires Chilkat v9.5.0.83 or greater.  The SHA3 hash algorithm is implemented in Chilkat v9.5.0.83, but not in earlier versions.
// IMPORTANT: This example requires Chilkat v9.5.0.83 or greater.  The SHA3 hash algorithm is implemented in Chilkat v9.5.0.83, but not in earlier versions.
// IMPORTANT: This example requires Chilkat v9.5.0.83 or greater.  The SHA3 hash algorithm is implemented in Chilkat v9.5.0.83, but not in earlier versions.
loo_Crypt.HashAlgorithm = "sha3-512"
loo_Crypt.EncodingMode = "hex"

ls_RequestId = "TSTKFT1222564"
ls_Timestamp = "2017-12-30T18:25:45.000Z"
ls_SignatureKey = "ce-8f5e-215119fa7dd621DLMRHRLH2S"

// Step 1: Concatenate requestId, UTC timestamp, and user's signature key.
loo_SbFinalHashBase = create oleobject
li_rc = loo_SbFinalHashBase.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

// First append the timestamp because we are going to remove certain chars/parts.
loo_SbFinalHashBase.Append(ls_Timestamp)
li_NumReplaced = loo_SbFinalHashBase.Replace(".000Z","")
li_NumReplaced = loo_SbFinalHashBase.Replace("-","")
li_NumReplaced = loo_SbFinalHashBase.Replace(":","")
li_NumReplaced = loo_SbFinalHashBase.Replace("T","")

// Prepend the requestId and append the signatureKey
loo_SbFinalHashBase.Prepend(ls_RequestId)
loo_SbFinalHashBase.Append(ls_SignatureKey)

// Step 2: Calculate first index hash.
ls_InvoiceOperation = "CREATE"
ls_InvoiceData = "QWJjZDEyMzQ="

loo_SbHashBase = create oleobject
li_rc = loo_SbHashBase.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_SbHashBase.Append(ls_InvoiceOperation)
loo_SbHashBase.Append(ls_InvoiceData)
Write-Debug "first hash base = " + loo_SbHashBase.GetAsString()

ls_FirstHash = loo_Crypt.HashStringENC(loo_SbHashBase.GetAsString())
Write-Debug "first hash = " + ls_FirstHash

// Output should be:
// first hash base = CREATEQWJjZDEyMzQ=
// first hash = 4317798460962869BC67F07C48EA7E4A3AFA301513CEB87B8EB94ECF92BC220A89C480F87F0860E85E29A3B6C0463D4F29712C5AD48104A6486CE839DC2F24CB

// Step 3: Calculate second index hash.
ls_InvoiceOperation = "MODIFY"
ls_InvoiceData = "RGNiYTQzMjE="

loo_SbHashBase.Clear()
loo_SbHashBase.Append(ls_InvoiceOperation)
loo_SbHashBase.Append(ls_InvoiceData)
Write-Debug "second hash base = " + loo_SbHashBase.GetAsString()

ls_SecondHash = loo_Crypt.HashStringENC(loo_SbHashBase.GetAsString())
Write-Debug "second hash = " + ls_SecondHash

// Output should be:
// second hash base = MODIFYRGNiYTQzMjE=
// second hash = A881218238933F6FFB9E167445CB4DAA9749BCF484FDE48AB7649FD25E8B634A4736A65A7C4A8E2831119F739837E006566F97370415AAD55E268605206F2A6C

// Step 4: Append the uppercase hex hashes to the sbFinalHashBase
loo_SbFinalHashBase.Append(ls_FirstHash)
loo_SbFinalHashBase.Append(ls_SecondHash)
Write-Debug "sbFinalHashBase = " + loo_SbFinalHashBase.GetAsString()

// Step 5: SHA3-512 hash to get the requestSignature
ls_RequestSignature = loo_Crypt.HashStringENC(loo_SbFinalHashBase.GetAsString())
Write-Debug "requestSignature = " + ls_RequestSignature

// Output should be:
// requestSignature = 60BC80609EE3B8F42FE904200A49A1921A1DADA08D55319ACD40C59F626514B74EEA49011D372600A10DBCF8199D590DA9C2841D987308F2D83DAE17C2470C42


destroy loo_Crypt
destroy loo_SbFinalHashBase
destroy loo_SbHashBase

 

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