![]() |
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.DecryptStringENC methodDemonstrates how to call the DecryptStringENC method.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int -- This example requires the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. 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' EXEC sp_OASetProperty @crypt, 'EncodingMode', 'base64' -- Return the base64 encoded encrypted bytes DECLARE @encodedEncrypted nvarchar(4000) EXEC sp_OAMethod @crypt, 'EncryptStringENC', @encodedEncrypted OUT, 'Hello World!' PRINT 'Encrypted: ' + @encodedEncrypted -- Output: -- Encrypted: qiq+IFhcjTkEIkZyf31V/g== -- Decrypt DECLARE @originalText nvarchar(4000) EXEC sp_OAMethod @crypt, 'DecryptStringENC', @originalText OUT, @encodedEncrypted PRINT 'Decrypted: ' + @originalText -- Output: -- Decrypted: Hello World! EXEC @hr = sp_OADestroy @crypt END GO |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.