Show / Hide Table of Contents

Interface ISymmetricCryptography

Service interface for symmetrically encrypting/decrypting data (raw byte[] arrays).

Please keep in mind that the data you encrypt with EncryptWithPassword(Byte[], String) can only be decrypted using the same password and the corresponding mirror method DecryptWithPassword(Byte[], String).

Likewise, data encrypted using Encrypt(Byte[]) can only be decrypted again using Decrypt(EncryptionResult) respectively.

Namespace: GlitchedPolygons.Services.Cryptography.Symmetric
Assembly: GlitchedPolygons.Services.Cryptography.Symmetric.dll
Syntax
public interface ISymmetricCryptography

Methods

| Improve this Doc View Source

Decrypt(EncryptionResult)

Decrypts the specified EncryptionResult that was obtained using Encrypt(Byte[]).

Declaration
byte[] Decrypt(EncryptionResult encryptionResult)
Parameters
Type Name Description
EncryptionResult encryptionResult

The EncryptionResult that was obtained using Encrypt(Byte[]).

Returns
Type Description
System.Byte[]

Decrypted byte[] array or null if decryption failed.

| Improve this Doc View Source

DecryptAsync(EncryptionResult)

Asynchronously decrypts the specified EncryptionResult that was obtained using EncryptAsync(Byte[]).

Declaration
Task<byte[]> DecryptAsync(EncryptionResult encryptionResult)
Parameters
Type Name Description
EncryptionResult encryptionResult

The EncryptionResult that was obtained using EncryptAsync(Byte[]).

Returns
Type Description
Task<System.Byte[]>

Decrypted byte[] or null if decryption failed.

| Improve this Doc View Source

DecryptWithPassword(Byte[], String)

Decrypts data that was encrypted using EncryptWithPassword(Byte[], String).

Declaration
byte[] DecryptWithPassword(byte[] encryptedBytes, string password)
Parameters
Type Name Description
System.Byte[] encryptedBytes

The encrypted data.

System.String password

The password that was used to encrypt the data.

Returns
Type Description
System.Byte[]

The decrypted byte[] array.

| Improve this Doc View Source

DecryptWithPassword(String, String)

Decrypts a string that was encrypted using EncryptWithPassword(String, String).

Declaration
string DecryptWithPassword(string data, string password)
Parameters
Type Name Description
System.String data

The encrypted data.

System.String password

The password that was used to encrypt the data.

Returns
Type Description
System.String

The decrypted data.

| Improve this Doc View Source

DecryptWithPasswordAsync(Byte[], String)

Asynchronously decrypts data that was encrypted using EncryptWithPasswordAsync(Byte[], String).

Declaration
Task<byte[]> DecryptWithPasswordAsync(byte[] encryptedBytes, string password)
Parameters
Type Name Description
System.Byte[] encryptedBytes

The encrypted data.

System.String password

The password that was used to encrypt the data.

Returns
Type Description
Task<System.Byte[]>

The decrypted byte[] array.

| Improve this Doc View Source

DecryptWithPasswordAsync(String, String)

Asynchronously decrypts a string that was encrypted using EncryptWithPasswordAsync(String, String).

Declaration
Task<string> DecryptWithPasswordAsync(string data, string password)
Parameters
Type Name Description
System.String data

The encrypted data string.

System.String password

The password that was used to encrypt the data.

Returns
Type Description
Task<System.String>

The decrypted string; string.Empty if you passed invalid arguments; null if decryption failed.

| Improve this Doc View Source

Encrypt(Byte[])

Encrypts the specified data using a randomly generated key and initialization vector.

Returns an EncryptionResult containing the encrypted byte[] array + the used encryption key and iv.

Declaration
EncryptionResult Encrypt(byte[] data)
Parameters
Type Name Description
System.Byte[] data

The data to encrypt.

Returns
Type Description
EncryptionResult

EncryptionResult containing the encrypted byte[] array + the used encryption key and iv.

| Improve this Doc View Source

EncryptAsync(Byte[])

Encrypts the specified data asynchronously using a randomly generated key and initialization vector.

Returns an EncryptionResult containing the encrypted byte[] array + the used encryption key and iv.

Declaration
Task<EncryptionResult> EncryptAsync(byte[] data)
Parameters
Type Name Description
System.Byte[] data

The data to encrypt.

Returns
Type Description
Task<EncryptionResult>

EncryptionResult containing the encrypted byte[] array + the used encryption key and iv.

| Improve this Doc View Source

EncryptWithPassword(Byte[], String)

Encrypts data using a password.

Declaration
byte[] EncryptWithPassword(byte[] data, string password)
Parameters
Type Name Description
System.Byte[] data

The data to encrypt.

System.String password

The password used to derive the AES key.

Returns
Type Description
System.Byte[]

The encrypted data bytes.

| Improve this Doc View Source

EncryptWithPassword(String, String)

Encrypts data using a password.

Declaration
string EncryptWithPassword(string data, string password)
Parameters
Type Name Description
System.String data

The data to encrypt.

System.String password

The password used to derive the AES key.

Returns
Type Description
System.String

The encrypted data; null if encryption failed; string.Empty if the passed parameters were invalid.

| Improve this Doc View Source

EncryptWithPasswordAsync(Byte[], String)

Encrypts data asynchronously using a password.

Declaration
Task<byte[]> EncryptWithPasswordAsync(byte[] data, string password)
Parameters
Type Name Description
System.Byte[] data

The data to encrypt.

System.String password

The password used to derive the AES key.

Returns
Type Description
Task<System.Byte[]>

The encrypted data bytes.

| Improve this Doc View Source

EncryptWithPasswordAsync(String, String)

Encrypts data asynchronously using a password.

Declaration
Task<string> EncryptWithPasswordAsync(string data, string password)
Parameters
Type Name Description
System.String data

The data to encrypt asynchronously.

System.String password

The password used to derive the AES key.

Returns
Type Description
Task<System.String>

The encrypted data.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX