C# Класс IronPigeon.CryptoProviderExtensions

Extension methods to the CryptoSettings interface.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
CreateWebSafeBase64Thumbprint ( this cryptoProvider, byte buffer ) : string

Creates a web safe base64 thumbprint of some buffer.

Decrypt ( this cryptoProvider, SymmetricEncryptionResult data ) : byte[]

Symmetrically decrypts a buffer using the specified key.

DecryptAsync ( this cryptoProvider, Stream ciphertext, Stream plaintext, SymmetricEncryptionVariables encryptionVariables, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Symmetrically decrypts a stream.

Encrypt ( this cryptoProvider, byte data, SymmetricEncryptionVariables encryptionVariables = null ) : SymmetricEncryptionResult

Symmetrically encrypts the specified buffer using a randomly generated key.

EncryptAsync ( this cryptoProvider, Stream plaintext, Stream ciphertext, SymmetricEncryptionVariables encryptionVariables = null, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Symmetrically encrypts a stream.

GetHashAlgorithmName ( this algorithm ) : string

Gets the name of the hash algorithm.

IsThumbprintMatch ( byte buffer, string allegedHashWebSafeBase64Thumbprint ) : bool

Determines whether a given thumbprint matches the actual hash of the specified buffer.

ParseHashAlgorithmName ( string algorithmName ) : HashAlgorithm?

Parses the name of the hash algorithm into an enum.

Приватные методы

Метод Описание
GetSignatureProvider ( string hashAlgorithm ) : AsymmetricAlgorithm

Gets the signature provider.

IsHashMatchWithTolerantHashAlgorithm ( this cryptoProvider, byte data, byte expectedHash, HashAlgorithm hashAlgorithm ) : bool

Computes the hash of the specified buffer and checks for a match to an expected hash.

NewSymmetricEncryptionVariables ( CryptoSettings cryptoProvider ) : SymmetricEncryptionVariables

Generates a new set of encryption variables.

ThisOrNewEncryptionVariables ( CryptoSettings cryptoProvider, SymmetricEncryptionVariables encryptionVariables ) : SymmetricEncryptionVariables

Returns the specified encryption variables if they are non-null, or generates new ones.

VerifySignatureWithTolerantHashAlgorithm ( byte signingPublicKey, byte data, byte signature, AsymmetricAlgorithm signingAlgorithm = null ) : bool

Verifies the asymmetric signature of some data blob.

Описание методов

CreateWebSafeBase64Thumbprint() публичный статический Метод

Creates a web safe base64 thumbprint of some buffer.
public static CreateWebSafeBase64Thumbprint ( this cryptoProvider, byte buffer ) : string
cryptoProvider this The crypto provider.
buffer byte The buffer.
Результат string

Decrypt() публичный статический Метод

Symmetrically decrypts a buffer using the specified key.
public static Decrypt ( this cryptoProvider, SymmetricEncryptionResult data ) : byte[]
cryptoProvider this The crypto provider.
data SymmetricEncryptionResult The encrypted data and the key and IV used to encrypt it.
Результат byte[]

DecryptAsync() публичный статический Метод

Symmetrically decrypts a stream.
public static DecryptAsync ( this cryptoProvider, Stream ciphertext, Stream plaintext, SymmetricEncryptionVariables encryptionVariables, CancellationToken cancellationToken = default(CancellationToken) ) : Task
cryptoProvider this The crypto provider.
ciphertext Stream The stream of ciphertext to decrypt.
plaintext Stream The stream to receive the plaintext.
encryptionVariables SymmetricEncryptionVariables The key and IV to use.
cancellationToken System.Threading.CancellationToken A cancellation token.
Результат Task

Encrypt() публичный статический Метод

Symmetrically encrypts the specified buffer using a randomly generated key.
public static Encrypt ( this cryptoProvider, byte data, SymmetricEncryptionVariables encryptionVariables = null ) : SymmetricEncryptionResult
cryptoProvider this The crypto provider.
data byte The data to encrypt.
encryptionVariables SymmetricEncryptionVariables Optional encryption variables to use; or null to use randomly generated ones.
Результат SymmetricEncryptionResult

EncryptAsync() публичный статический Метод

Symmetrically encrypts a stream.
public static EncryptAsync ( this cryptoProvider, Stream plaintext, Stream ciphertext, SymmetricEncryptionVariables encryptionVariables = null, CancellationToken cancellationToken = default(CancellationToken) ) : Task
cryptoProvider this The crypto provider.
plaintext Stream The stream of plaintext to encrypt.
ciphertext Stream The stream to receive the ciphertext.
encryptionVariables SymmetricEncryptionVariables An optional key and IV to use. May be null to use randomly generated values.
cancellationToken System.Threading.CancellationToken A cancellation token.
Результат Task

GetHashAlgorithmName() публичный статический Метод

Gets the name of the hash algorithm.
public static GetHashAlgorithmName ( this algorithm ) : string
algorithm this The algorithm.
Результат string

IsThumbprintMatch() публичный статический Метод

Determines whether a given thumbprint matches the actual hash of the specified buffer.
If the length of the thumbprint is not consistent with any supported hash algorithm.
public static IsThumbprintMatch ( byte buffer, string allegedHashWebSafeBase64Thumbprint ) : bool
buffer byte The buffer.
allegedHashWebSafeBase64Thumbprint string The web-safe base64 encoding of the thumbprint that the specified buffer's thumbprint is expected to match.
Результат bool

ParseHashAlgorithmName() публичный статический Метод

Parses the name of the hash algorithm into an enum.
public static ParseHashAlgorithmName ( string algorithmName ) : HashAlgorithm?
algorithmName string Name of the algorithm. Null is allowed.
Результат HashAlgorithm?