![]() |
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) Transition from RandomizeKey to GenRandomBytesENCProvides instructions for replacing deprecated RandomizeKey method calls with GenRandomBytesENC. Note: This example requires Chilkat v11.0.0 or greater.
-- 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', 256 -- ... -- ------------------------------------------------------------------------ -- The RandomizeKey method is deprecated: -- Generates and sets a random 32-byte (256-bit) secret key. EXEC sp_OAMethod @crypt, 'RandomizeKey', NULL -- ------------------------------------------------------------------------ -- Do the equivalent using GenRandomBytesENC followed by SetEncodedKey EXEC sp_OASetProperty @crypt, 'EncodingMode', 'base64' DECLARE @randomKeyBase64 nvarchar(4000) EXEC sp_OAMethod @crypt, 'GenRandomBytesENC', @randomKeyBase64 OUT, 32 EXEC sp_OAMethod @crypt, 'SetEncodedKey', NULL, @randomKeyBase64, 'base64' EXEC @hr = sp_OADestroy @crypt END GO |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.