![]() |
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
(SQL Server) Example: Crypt2.EncryptEncoded methodDemonstrates how to call the EncryptEncoded method.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @crypt int EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END EXEC sp_OASetProperty @crypt, 'CryptAlgorithm', 'aes' EXEC sp_OASetProperty @crypt, 'CipherMode', 'cbc' EXEC sp_OASetProperty @crypt, 'KeyLength', 128 EXEC sp_OAMethod @crypt, 'SetEncodedKey', NULL, '000102030405060708090A0B0C0D0E0F', 'hex' EXEC sp_OAMethod @crypt, 'SetEncodedIV', NULL, '000102030405060708090A0B0C0D0E0F', 'hex' -- Encrypt the bytes 0x00, 0x01, 0x02, ... 0x0A -- and return the encrypted bytes using the lowercase hex encoding. EXEC sp_OASetProperty @crypt, 'EncodingMode', 'hex_lower' DECLARE @encrypted nvarchar(4000) EXEC sp_OAMethod @crypt, 'EncryptEncoded', @encrypted OUT, '000102030405060708090a' PRINT @encrypted -- Output: -- 9da2ae71a5378487114b430e5e230378 DECLARE @decrypted nvarchar(4000) EXEC sp_OAMethod @crypt, 'DecryptEncoded', @decrypted OUT, @encrypted PRINT @decrypted -- Output: -- 000102030405060708090a EXEC @hr = sp_OADestroy @crypt END GO |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.