![]() |
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.SetDecryptCert methodDemonstrates how to call the SetDecryptCert method.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) DECLARE @cert int EXEC @hr = sp_OACreate 'Chilkat.Cert', @cert OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int EXEC sp_OAMethod @cert, 'LoadPfxFile', @success OUT, 'c:/pfx_files/my.pfx', 'password' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @cert, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @cert RETURN END DECLARE @decrypt int EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @decrypt OUT EXEC sp_OASetProperty @decrypt, 'CryptAlgorithm', 'pki' EXEC sp_OAMethod @decrypt, 'SetDecryptCert', @success OUT, @cert IF @success <> 1 BEGIN EXEC sp_OAGetProperty @decrypt, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @cert EXEC @hr = sp_OADestroy @decrypt RETURN END DECLARE @bd int EXEC @hr = sp_OACreate 'Chilkat.BinData', @bd OUT EXEC sp_OAMethod @bd, 'LoadFile', @success OUT, 'c:/someDir/pkcs7_encrypted.dat' EXEC sp_OAMethod @decrypt, 'DecryptBd', @success OUT, @bd IF @success <> 1 BEGIN EXEC sp_OAGetProperty @decrypt, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @cert EXEC @hr = sp_OADestroy @decrypt EXEC @hr = sp_OADestroy @bd RETURN END -- bd contains the decrypted content. EXEC @hr = sp_OADestroy @cert EXEC @hr = sp_OADestroy @decrypt EXEC @hr = sp_OADestroy @bd END GO |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.