CryptoSys API Library Manual

Using with .NET: C# and VB.NET

To use the .NET interface with C# and VB.NET (VB2010+):

  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 or use the class library DLL.

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

Unhandled Exception: System.DllNotFoundException: 
Unable to load DLL 'diCryptoSys.dll': 
The specified module could not be found. 
(Exception from HRESULT: 0x8007007E)

If you are working on a 64-bit system, Visual Studio will go looking for the 64-bit core DLL in the Windows system folder (usually C:\Windows\System32). Make sure you set the Solution Platform to be Any CPU.

The .NET class library diCrSysAPINet.dll is compiled for all platforms (Win32 and X64) and requires at least .NET 4.0 and should be upwardly compatible with all later .NET versions. This means that you must be using VS2010 or later.

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.

If you need to convert existing VB6 code, see Converting VB6 to VB.NET.

[PREV: Using with C++ (STL)...]   [Contents]   [Index]   
   [NEXT: Combining bitwise options...]

Copyright © 2001-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-01-07T07:42:00Z.