SQL Server Stored Procedure Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

SQL Server
Stored Procedure Examples

Quick Start
Encryption
File Access
IMAP
POP3
SMTP
Email Object
FTP
HTML-to-XML
HTTP
MHT
MIME
RSA Encryption
Socket
Spider
String
Tar
Upload
XML
XMP
Zip

Byte Array
RSS
Atom
Self-Extractor

Verify .p7s and Extract Original File

SQL Server example to verify and unpack the contents of a .p7s to restore the original file.

Download Chilkat Crypt ActiveX

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @crypt int
    EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    --  Any string argument automatically begins the 30-day trial.
    DECLARE @success int

    EXEC sp_OAMethod @crypt, 'UnlockComponent', @success OUT, '30-day trial'
    IF @success <> 1
      BEGIN
        PRINT 'Crypt component unlock failed'
        RETURN
      END

    --  Find our digital certificate from the Current User certificate store.
    DECLARE @ccs int
    EXEC @hr = sp_OACreate 'Chilkat.CreateCS', @ccs OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @certStore int

    EXEC sp_OAMethod @ccs, 'OpenCurrentUserStore', @certStore OUT
    DECLARE @cert int

    EXEC sp_OAMethod @certStore, 'FindCertBySubjectCN', @cert OUT, 'Chilkat Software, Inc.'
    IF @cert Is NULL 
      BEGIN
        EXEC sp_OAGetProperty @cert, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0

        RETURN
      END

    --  Verify and restore the original file:
    EXEC sp_OAMethod @crypt, 'SetVerifyCert', NULL, @cert

    EXEC sp_OAMethod @crypt, 'VerifyP7S', @success OUT, 'license.p7s', 'license2.rtf'
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @crypt, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0

        RETURN
      END

    PRINT 'Success!'
END
GO

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.