![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(AutoIt) Everyware API RSA Encrypt JSONSee more RSA ExamplesDemonstrates how to RSA encrypt JSON using everyware.com's RSA public key.Note: This example requires Chilkat v11.0.0 or greater. For more information, see https://docs.everyware.com/docs/access-iframe#sample-json--encrypted-payload
Local $bSuccess = False ; 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. $oJson = ObjCreate("Chilkat.JsonObject") $oJson.UpdateString("provider_key","USER GUID HERE") $oJson.UpdateString("menu_item","payment") $oDt = ObjCreate("Chilkat.CkDateTime") $oDt.SetFromCurrentSystemTime() $oJson.UpdateString("date_time",$oDt.GetAsUnixTimeStr(False)) ; 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 $oJson.EmitCompact = True ; Everyware's RSA public key is at: https://docs.everyware.com/docs/everyware-public-rsa-key $oSb = ObjCreate("Chilkat.StringBuilder") Local $bCrlf = True $oSb.AppendLine("-----BEGIN PUBLIC KEY-----",$bCrlf) $oSb.AppendLine("MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxNbflxUSWQ3XJ1N9dAoh",$bCrlf) $oSb.AppendLine("k+uaiFsg3wkPi9LGS/mH8DtHBgZxKyz+oQBDtnDd9FDEo0ql7MMgCMsTAv27W5vk",$bCrlf) $oSb.AppendLine("Pu0rm6zhcTeYquWEuVCS7VtVsyTATr0Z9WhqNeZlIRurovJAXl2jRDX6QeY5dayC",$bCrlf) $oSb.AppendLine("ubwyG4lBWE4fCakGY6zlh+oaElK0rvblqjYoEg3dn4KPRCYGof8OFxLptHThD4cE",$bCrlf) $oSb.AppendLine("T30j+utVafhO0HRyJ4iR3Pigb4GXdWBtJEEEWddZJizMkjFQkyUAoYLOT8EJ2TW3",$bCrlf) $oSb.AppendLine("Tz8SvAuHBUEFcPWTSTMAG/bSp5wrYBTXaeEhx+wrYa60OruHuzgmhzKyQVuYlCNJ",$bCrlf) $oSb.AppendLine("HdbnassuIRjjSNo25o4AdSlWwpGfBZjAiyEInR+KGpHdhKTxSekJxiwiXUS0UfSG",$bCrlf) $oSb.AppendLine("prOpd5PzWaAR7DvjLsdmR9XffxvJCVxC735gLK7hDJKjCajDPHVDr8FSL8xMlrq0",$bCrlf) $oSb.AppendLine("nKxtsHeRl1yzoGrRr12+9MiQnHtpqROTNXcXdwe3v+Vh8V5k8v8oIrcgh1+/N7Bd",$bCrlf) $oSb.AppendLine("NiRsy1gFHBdu/he/KcDRT/9/acQFMPLQueGfZxUvU5As6pEONjtKX2MUg2fMF6Rc",$bCrlf) $oSb.AppendLine("sQVVrLzg0g7EcuHGfuPeKfD/716MvS8NU7rX+2soijCSQv/e18PJPMVDlcMXjnup",$bCrlf) $oSb.AppendLine("PPx1tStemesavFlj1okhS6UCAwEAAQ==",$bCrlf) $oSb.AppendLine("-----END PUBLIC KEY-----",$bCrlf) $oPubkey = ObjCreate("Chilkat.PublicKey") $bSuccess = $oPubkey.LoadFromString($oSb.GetAsString()) If ($bSuccess = False) Then ConsoleWrite($oPubkey.LastErrorText & @CRLF) Exit EndIf $oRsa = ObjCreate("Chilkat.Rsa") $bSuccess = $oRsa.UsePublicKey($oPubkey) If ($bSuccess = False) Then ConsoleWrite($oRsa.LastErrorText & @CRLF) Exit EndIf ; 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) $oRsa.EncodingMode = "base64url" Local $sEncryptedJson = $oRsa.EncryptStringENC($oJson.Emit(),False) ; Build the URL ; Such as: https://portal.everyware.com/Account/LoginMenu?data={Base64Url_encrypted_JSON} $oSbUrl = ObjCreate("Chilkat.StringBuilder") $oSbUrl.Append("https://portal.everyware.com/Account/LoginMenu?data=") $oSbUrl.Append($sEncryptedJson) ConsoleWrite($oSbUrl.GetAsString() & @CRLF) |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.