CryptoSys API Library Manual

Using with .NET: C# and VB.NET

To use the .NET interface with C# and VB.NET (VB2005/VB2008/VB200x):

  1. Copy the dotnet diCrSysAPINet.dll library file into a convenient folder.
  2. In your application, add a reference to the library:
    1. Project > Add Reference.
    2. In the .NET tab, click on the Browse button to find and select the library file diCrSysAPINet.dll.
    3. Click on OK and the wizard will add the reference of the class library to your project.
  3. Add the line (for C#)
    using CryptoSysAPI;
    
    or (for VB.NET)
    Imports CryptoSysAPI
    

    to your code.

  4. Call the methods in the various classes. Note that the methods in the .NET interface may have different parameters and return values to the functions in the core VB6/C DLL.

Alternatively, with C#, you can just include the source code module CryptoSysAPI.cs in your project and there is no need to reference the class library DLL.

Note that you must also have the core Win32 (or X64) executable diCrPKI.dll installed on your system for the .NET interface to work. If not, it will throw an exception immediately.

There are two different types of methods used in the .NET interface:-

  1. A simple static method. These carry out the cryptographic operation with the given parameters and return the result in a "one-off" operation. These are the simplest methods to use and are recommended in all environments if you know in advance what your data consists of.
  2. An "incremental" interface using object-oriented Init/Update/Dispose methods that create an instance and allow the user to add data continuously in blocks of any (valid) length. Use these methods when your data is not available in one chunk and you need to operate on streaming data.

We recommend that you use the static "one-off" methods unless you really have to deal with streaming data of unknown length.

For examples, see the test code TestAPIcsharp.cs and TestAPIvbnet.vb provided in the distribution.

In older versions, we suggested using direct upgrades of the VB6 code in VB.NET with all the pre-dimensioning and other unsafe practices. The .NET Class Library interface is cleaner, safer and more convenient. If you are writing VB.NET code from scratch, please use the .NET Class Library interface. If you need to convert existing VB6 code, see Converting VB6 to VB.NET.

[Contents] [Index]

[HOME]   [NEXT: Converting VB6 to VB.NET...]

Copyright © 2001-9 D.I. Management Services Pty Ltd. All rights reserved.