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

Classic ASP 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
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

 

 

 

(Classic ASP) Everyware API RSA Encrypt JSON

See more RSA Examples

Demonstrates how to RSA encrypt JSON using everyware.com's RSA public key.

For more information, see https://docs.everyware.com/docs/access-iframe#sample-json--encrypted-payload

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

' First build the JSON to be encrypted.
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set json = Server.CreateObject("Chilkat.JsonObject")
success = json.UpdateString("provider_key","USER GUID HERE")
success = json.UpdateString("menu_item","payment")
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.CkDateTime")
set dt = Server.CreateObject("Chilkat.CkDateTime")
success = dt.SetFromCurrentSystemTime()
success = json.UpdateString("date_time",dt.GetAsUnixTimeStr(0))

' This build JSON like the following:

' {
'     "provider_key": "USER GUID HERE",
'     "menu_item": "payment",
'     "date_time": "1588163411"
' }

' When we sign, we'll want to sign the most compact JSON possible
json.EmitCompact = 1

' Everyware's RSA public key is at:  https://docs.everyware.com/docs/everyware-public-rsa-key
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder")
set sb = Server.CreateObject("Chilkat.StringBuilder")
bCrlf = 1
success = sb.AppendLine("-----BEGIN PUBLIC KEY-----",bCrlf)
success = sb.AppendLine("MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxNbflxUSWQ3XJ1N9dAoh",bCrlf)
success = sb.AppendLine("k+uaiFsg3wkPi9LGS/mH8DtHBgZxKyz+oQBDtnDd9FDEo0ql7MMgCMsTAv27W5vk",bCrlf)
success = sb.AppendLine("Pu0rm6zhcTeYquWEuVCS7VtVsyTATr0Z9WhqNeZlIRurovJAXl2jRDX6QeY5dayC",bCrlf)
success = sb.AppendLine("ubwyG4lBWE4fCakGY6zlh+oaElK0rvblqjYoEg3dn4KPRCYGof8OFxLptHThD4cE",bCrlf)
success = sb.AppendLine("T30j+utVafhO0HRyJ4iR3Pigb4GXdWBtJEEEWddZJizMkjFQkyUAoYLOT8EJ2TW3",bCrlf)
success = sb.AppendLine("Tz8SvAuHBUEFcPWTSTMAG/bSp5wrYBTXaeEhx+wrYa60OruHuzgmhzKyQVuYlCNJ",bCrlf)
success = sb.AppendLine("HdbnassuIRjjSNo25o4AdSlWwpGfBZjAiyEInR+KGpHdhKTxSekJxiwiXUS0UfSG",bCrlf)
success = sb.AppendLine("prOpd5PzWaAR7DvjLsdmR9XffxvJCVxC735gLK7hDJKjCajDPHVDr8FSL8xMlrq0",bCrlf)
success = sb.AppendLine("nKxtsHeRl1yzoGrRr12+9MiQnHtpqROTNXcXdwe3v+Vh8V5k8v8oIrcgh1+/N7Bd",bCrlf)
success = sb.AppendLine("NiRsy1gFHBdu/he/KcDRT/9/acQFMPLQueGfZxUvU5As6pEONjtKX2MUg2fMF6Rc",bCrlf)
success = sb.AppendLine("sQVVrLzg0g7EcuHGfuPeKfD/716MvS8NU7rX+2soijCSQv/e18PJPMVDlcMXjnup",bCrlf)
success = sb.AppendLine("PPx1tStemesavFlj1okhS6UCAwEAAQ==",bCrlf)
success = sb.AppendLine("-----END PUBLIC KEY-----",bCrlf)

' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.PublicKey")
set pubkey = Server.CreateObject("Chilkat.PublicKey")
success = pubkey.LoadFromString(sb.GetAsString())
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( pubkey.LastErrorText) & "</pre>"
    Response.End
End If

' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Rsa")
set rsa = Server.CreateObject("Chilkat.Rsa")
success = rsa.ImportPublicKeyObj(pubkey)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( rsa.LastErrorText) & "</pre>"
    Response.End
End If

' We probably need a base64Url encoded encrypted key.
' Using straight-up base64 would potenially include chars that are not URL safe (i.e. have special meanings in URLs)
rsa.EncodingMode = "base64url"

encryptedJson = rsa.EncryptStringENC(json.Emit(),0)

' Build the URL
' Such as:  https://portal.everyware.com/Account/LoginMenu?data={Base64Url_encrypted_JSON}
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder")
set sbUrl = Server.CreateObject("Chilkat.StringBuilder")
success = sbUrl.Append("https://portal.everyware.com/Account/LoginMenu?data=")
success = sbUrl.Append(encryptedJson)

Response.Write "<pre>" & Server.HTMLEncode( sbUrl.GetAsString()) & "</pre>"

%>
</body>
</html>

 

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