using Net.Pkcs11Interop.HighLevelAPI; using Net.Pkcs11Interop.Common; ICryptoServiceProvider cryptoServiceProvider = new CsharpPkcs11CryptoServiceProvider("C:\\Windows\\System32\\pkcs11.dll"); ISession session = cryptoServiceProvider.DeriveSession(CKU.CKU_SO); session.Login(CKU.CKU_SO, "my_so_pin");
using Net.Pkcs11Interop.HighLevelAPI; using Net.Pkcs11Interop.Common; ICryptoServiceProvider cryptoServiceProvider = new CsharpPkcs11CryptoServiceProvider("C:\\Windows\\System32\\pkcs11.dll"); ISession session = cryptoServiceProvider.DeriveSession(CKU.CKU_USER); session.Login(CKU.CKU_USER, "my_user_pin"); byte[] dataFromSmartcard = session.Read("0123456789AB");In both examples, we use the CsharpPkcs11 library to instantiate a PKCS#11 object (in this case, a CryptoServiceProvider). We then derive a session with a login pin, and perform operations such as reading data from a smart card. The CsharpPkcs11 library is available as a NuGet package and requires the installation of the appropriate PKCS#11 device driver.