Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Visual FoxPro) Everyware API RSA Encrypt JSONSee more RSA ExamplesDemonstrates 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
LOCAL lnSuccess LOCAL loJson LOCAL loDt LOCAL loSb LOCAL lnBCrlf LOCAL loPubkey LOCAL loRsa LOCAL lcEncryptedJson LOCAL loSbUrl * 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') loJson = CreateObject('Chilkat.JsonObject') loJson.UpdateString("provider_key","USER GUID HERE") loJson.UpdateString("menu_item","payment") * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.CkDateTime') loDt = CreateObject('Chilkat.CkDateTime') loDt.SetFromCurrentSystemTime() loJson.UpdateString("date_time",loDt.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 loJson.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') loSb = CreateObject('Chilkat.StringBuilder') lnBCrlf = 1 loSb.AppendLine("-----BEGIN PUBLIC KEY-----",lnBCrlf) loSb.AppendLine("MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxNbflxUSWQ3XJ1N9dAoh",lnBCrlf) loSb.AppendLine("k+uaiFsg3wkPi9LGS/mH8DtHBgZxKyz+oQBDtnDd9FDEo0ql7MMgCMsTAv27W5vk",lnBCrlf) loSb.AppendLine("Pu0rm6zhcTeYquWEuVCS7VtVsyTATr0Z9WhqNeZlIRurovJAXl2jRDX6QeY5dayC",lnBCrlf) loSb.AppendLine("ubwyG4lBWE4fCakGY6zlh+oaElK0rvblqjYoEg3dn4KPRCYGof8OFxLptHThD4cE",lnBCrlf) loSb.AppendLine("T30j+utVafhO0HRyJ4iR3Pigb4GXdWBtJEEEWddZJizMkjFQkyUAoYLOT8EJ2TW3",lnBCrlf) loSb.AppendLine("Tz8SvAuHBUEFcPWTSTMAG/bSp5wrYBTXaeEhx+wrYa60OruHuzgmhzKyQVuYlCNJ",lnBCrlf) loSb.AppendLine("HdbnassuIRjjSNo25o4AdSlWwpGfBZjAiyEInR+KGpHdhKTxSekJxiwiXUS0UfSG",lnBCrlf) loSb.AppendLine("prOpd5PzWaAR7DvjLsdmR9XffxvJCVxC735gLK7hDJKjCajDPHVDr8FSL8xMlrq0",lnBCrlf) loSb.AppendLine("nKxtsHeRl1yzoGrRr12+9MiQnHtpqROTNXcXdwe3v+Vh8V5k8v8oIrcgh1+/N7Bd",lnBCrlf) loSb.AppendLine("NiRsy1gFHBdu/he/KcDRT/9/acQFMPLQueGfZxUvU5As6pEONjtKX2MUg2fMF6Rc",lnBCrlf) loSb.AppendLine("sQVVrLzg0g7EcuHGfuPeKfD/716MvS8NU7rX+2soijCSQv/e18PJPMVDlcMXjnup",lnBCrlf) loSb.AppendLine("PPx1tStemesavFlj1okhS6UCAwEAAQ==",lnBCrlf) loSb.AppendLine("-----END PUBLIC KEY-----",lnBCrlf) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.PublicKey') loPubkey = CreateObject('Chilkat.PublicKey') lnSuccess = loPubkey.LoadFromString(loSb.GetAsString()) IF (lnSuccess = 0) THEN ? loPubkey.LastErrorText RELEASE loJson RELEASE loDt RELEASE loSb RELEASE loPubkey CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Rsa') loRsa = CreateObject('Chilkat.Rsa') lnSuccess = loRsa.ImportPublicKeyObj(loPubkey) IF (lnSuccess = 0) THEN ? loRsa.LastErrorText RELEASE loJson RELEASE loDt RELEASE loSb RELEASE loPubkey RELEASE loRsa CANCEL 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) loRsa.EncodingMode = "base64url" lcEncryptedJson = loRsa.EncryptStringENC(loJson.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') loSbUrl = CreateObject('Chilkat.StringBuilder') loSbUrl.Append("https://portal.everyware.com/Account/LoginMenu?data=") loSbUrl.Append(lcEncryptedJson) ? loSbUrl.GetAsString() RELEASE loJson RELEASE loDt RELEASE loSb RELEASE loPubkey RELEASE loRsa RELEASE loSbUrl |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.