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) Simple AES ECB DecryptionSee more Encryption ExamplesDecrypt 256-bit encrypted content.
-- 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 assumes the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. DECLARE @crypt int -- Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END -- Encrypted content (base64-encoded) DECLARE @ct nvarchar(4000) SELECT @ct = 'd/95VziAnUNKkpXr3dJBFcQqAEDWlDkc7EU2jLkYPxmr6PpLRJlgHos+/Uy28CvJsmztQ3JkJAMukVoj46QJ/7RMuqLb31cSKd1ZvMzx9J9b6q0EkmPJcSfBhf2x7v5Qvq3lz1EIH7RM61cDGf+g9p4lt6FtU2MzCqtYD+Vr29voCn5WU1CnXmks64RrbyDA1DDHOx2deJ4Kn68+KoPM9tAw9kbf4HApL1nJYU3Mfzl+MnuHuB2kJpL5GqbuNvS+4QjxuwtNGuZEEY0gOS4RIvWl/XfkxtWHMkzsKy08AO792xDGer4rL4Q1NcfI/H2V' -- 256-bit AES key (literally the 32 us-ascii bytes of this string) DECLARE @key nvarchar(4000) SELECT @key = 'sQsPQYesBM5qEM5OSxicFatIiLM459Bu' -- Note: If your AES key is a string, and it's not clearly hex or base64, AND if the length of the string is the exact size of the AES key, -- then *literally* use the ascii chars as the AES key. EXEC sp_OASetProperty @crypt, 'CryptAlgorithm', 'aes' EXEC sp_OASetProperty @crypt, 'CipherMode', 'ecb' EXEC sp_OASetProperty @crypt, 'KeyLength', 256 -- use the exact ascii bytes as the key. EXEC sp_OAMethod @crypt, 'SetEncodedKey', NULL, @key, 'ascii' EXEC sp_OASetProperty @crypt, 'EncodingMode', 'base64' DECLARE @pt nvarchar(4000) EXEC sp_OAMethod @crypt, 'DecryptStringENC', @pt OUT, @ct PRINT @pt EXEC @hr = sp_OADestroy @crypt END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.