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
(SQL Server) Load EC Public Key from X,Y ValuesDemonstrates how to load an EC public key from X and Y values.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) DECLARE @success int -- We have the following x and y values in base64 (for an EC point on the P-256 curve). DECLARE @x nvarchar(4000) SELECT @x = 'Dn7uB1O7kgk74G6qfQwFJESeDnxO6lLjGZFWZJE16tw' DECLARE @y nvarchar(4000) SELECT @y = 'iOWA5DInzK6nuUGvHJbMVq1Dpj248FqSV2teN3HzmhU' -- Build a JWK that looks like this: -- { -- "kty": "EC", -- "crv": "P-256", -- "x": "Dn7uB1O7kgk74G6qfQwFJESeDnxO6lLjGZFWZJE16tw", -- "y": "iOWA5DInzK6nuUGvHJbMVq1Dpj248FqSV2teN3HzmhU" -- } DECLARE @json int -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'kty', 'EC' EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'crv', 'P-256' EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'x', @x EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'y', @y -- Load from the JWK. DECLARE @pubkey int -- Use "Chilkat_9_5_0.PublicKey" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.PublicKey', @pubkey OUT EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT EXEC sp_OAMethod @pubkey, 'LoadFromString', @success OUT, @sTmp0 IF @success = 0 BEGIN EXEC sp_OAGetProperty @pubkey, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @json EXEC @hr = sp_OADestroy @pubkey RETURN END PRINT 'Success.' EXEC @hr = sp_OADestroy @json EXEC @hr = sp_OADestroy @pubkey END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.