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

Tcl 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
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
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

 

 

 

(Tcl) ChartURL - Create a Signed URL

Demonstrates how to create a signed URL for ChartURL.

Chilkat Tcl Extension Downloads

Chilkat Tcl Extension Downloads

load ./chilkat.dll

#  This example assumes Chilkat Crypt2 to have been previously unlocked.
#  See Unlock Crypt2 for sample code.

set crypt [new_CkCrypt2]

#  Example key: "dek-d7a46236eda961a6c3c18ffcc6b077ba87d27e9ae85f7842c6d427c265dd5f69d5131308d93332353d4a55a4b1160fcf516515a4a9f0aa50fbf2d7a2e7d0f1c5"
set key "charturl-sign-encrypt-key"
#  Example token: "dt-RwYN"
set token "charturl-token"

set slug "weekly-activity"
set data "{ \"options\": {\"data\": {\"columns\": [[\"This Week\",10,13],[\"Last Week\",9,5]]}}}"

CkCrypt2_put_HashAlgorithm $crypt "SHA256"
CkCrypt2_put_MacAlgorithm $crypt "HMAC"
CkCrypt2_SetMacKeyString $crypt $key
CkCrypt2_put_EncodingMode $crypt "base64"

set json [new_CkJsonObject]

CkJsonObject_Load $json $data
puts "json = [CkJsonObject_emit $json]"

set sig [CkCrypt2_macStringENC $crypt [CkJsonObject_emit $json]]

set sbUrl [new_CkStringBuilder]

CkStringBuilder_Append $sbUrl "https://charturl.com/i/"
CkStringBuilder_Append $sbUrl $token
CkStringBuilder_Append $sbUrl "/"
CkStringBuilder_Append $sbUrl $slug
CkStringBuilder_Append $sbUrl "?d="
CkStringBuilder_Append $sbUrl [CkCrypt2_encodeString $crypt [CkJsonObject_emit $json] "utf-8" "url"]
CkStringBuilder_Append $sbUrl "&s="
CkStringBuilder_Append $sbUrl [CkCrypt2_encodeString $crypt $sig "utf-8" "url"]

puts "Signed URL: [CkStringBuilder_getAsString $sbUrl]"

delete_CkCrypt2 $crypt
delete_CkJsonObject $json
delete_CkStringBuilder $sbUrl

 

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