CryptoServiceProvider Class
Provides methods and properties for accessing or examining Cryptographic Service Providers (CSPs) registered in the system.
Inheritance Hierarchy
SystemObject
  MailBee.SecurityCryptoServiceProvider

Namespace: MailBee.Security
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public class CryptoServiceProvider : IDisposable

The CryptoServiceProvider type exposes the following members.

Constructors
  NameDescription
Public methodCryptoServiceProvider
Creates a new instance of CryptoServiceProvider class.
Public methodCryptoServiceProvider(String)
Creates a new instance of CryptoServiceProvider class.
Top
Methods
  NameDescription
Public methodDispose
Releases the resources associated with the current CryptoServiceProvider object.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodCode exampleGetKeyContainer
Gets the name of the key container.
Public methodCode exampleGetProviderName
Gets the name of the CSP represented by this object.
Public methodCode exampleGetProviderVersion
Gets the version of the CSP represented by this object.
Public methodCode exampleGetSupportedAlgorithms
Gets the array of all cryptographic algorithms supported by the CSP.
Public methodStatic memberCode exampleGetSystemProviders
Gets the list of all CPSs that are registered in the operating system.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Fields
  NameDescription
Public fieldStatic memberBase
Gets Microsoft Base Cryptographic Provider name.
Public fieldStatic memberEnhanced
Gets Microsoft Enhanced Cryptographic Provider name.
Public fieldStatic memberStrong
Gets Microsoft Strong Cryptographic Provider name.
Top
Properties
  NameDescription
Public propertyLastResult
Gets a numeric code of the last error.
Public propertyThrowExceptions
Gets or sets whether the object will throw exceptions on errors.
Top
Remarks
CSP is an independent software module which performs cryptographic algorithms for authentication, encoding and encryption procedures. Each CSP supports its own set of algorithms.
Note Note
MailBee handles CSPs automatically. Usually there is no need to use CryptoServiceProvider class unless you need to use specific CSP. Although Smime class does offer Provider property, it's ignored by most editions of MailBee.NET Objects library.
Note Note
UWP and .NET Standard 2.0+ editions don't support this class at all. With these editions, the class is not defined or has no public members.
Examples
This sample displays the details of the default CSP to be used by MailBee, then changes the default CSP and displays its details, then creates a new CSP and displays its details.
// To use the code below, import these namespace at the top of your code
using System;
using MailBee.Security;

// The actual code (put it into a method of your class)

Smime objSmime = new Smime();

// Use default CSP.
Console.WriteLine(objSmime.Provider.GetProviderName());
Console.WriteLine(objSmime.Provider.GetProviderVersion());
Console.WriteLine(objSmime.Provider.GetKeyContainer());
Console.WriteLine("-----------------------------------");

// Set new default for CSP.
objSmime.Provider = new CryptoServiceProvider(CryptoServiceProvider.Enhanced);

// Use the new default CSP.
Console.WriteLine(objSmime.Provider.GetProviderName());
Console.WriteLine(objSmime.Provider.GetProviderVersion());
Console.WriteLine(objSmime.Provider.GetKeyContainer());
Console.WriteLine("-----------------------------------");

// Set new default for CSP.
CryptoServiceProvider strongProvider = new CryptoServiceProvider(CryptoServiceProvider.Strong);
objSmime.Provider = strongProvider;

// Use another CSP.
Console.WriteLine(objSmime.Provider.GetProviderName());
Console.WriteLine(objSmime.Provider.GetProviderVersion());
Console.WriteLine(objSmime.Provider.GetKeyContainer());
Console.WriteLine("-----------------------------------");
See Also