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) ARC4 PRNG (Pseudo Random Number Generator)Uses the ARC4 stream encryption algorithm as a pseudo random number generator.
-- 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 -- 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 -- Set the encryption algorithm to ARC4: EXEC sp_OASetProperty @crypt, 'CryptAlgorithm', 'arc4' -- We want the encrypted output to be a hex-encoded string. EXEC sp_OASetProperty @crypt, 'EncodingMode', 'hex' DECLARE @key nvarchar(4000) SELECT @key = '000102030405060708090A0B0C0D0E0F' DECLARE @data nvarchar(4000) SELECT @data = '12345678' -- Key length is 128 bits in this example. EXEC sp_OASetProperty @crypt, 'KeyLength', 128 EXEC sp_OAMethod @crypt, 'SetEncodedKey', NULL, @key, 'hex' -- Generate 16 "random" 8-byte blocks, encoded as hex strings. -- This example will generate the identical output each time -- it is run. DECLARE @cipherHex nvarchar(4000) DECLARE @i int SELECT @i = 0 WHILE @i <= 15 BEGIN EXEC sp_OAMethod @crypt, 'EncryptStringENC', @cipherHex OUT, @data PRINT @data PRINT @cipherHex SELECT @data = @cipherHex SELECT @i = @i + 1 END EXEC @hr = sp_OADestroy @crypt END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.