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
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 |
|---|---|
| byte[] | Decrypted |
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<byte[]> | Decrypted |
DecryptWithPassword(byte[], string)
Decrypts data that was encrypted using EncryptWithPassword(byte[], string).
Declaration
byte[] DecryptWithPassword(byte[] encryptedBytes, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | encryptedBytes | The encrypted data. |
| string | password | The password that was used to encrypt the data. |
Returns
| Type | Description |
|---|---|
| byte[] | The decrypted |
DecryptWithPassword(string, string)
Decrypts a string that was encrypted using EncryptWithPassword(string, string).
Declaration
string DecryptWithPassword(string data, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| string | data | The encrypted data. |
| string | password | The password that was used to encrypt the data. |
Returns
| Type | Description |
|---|---|
| string | The decrypted data. |
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 |
|---|---|---|
| byte[] | encryptedBytes | The encrypted data. |
| string | password | The password that was used to encrypt the data. |
Returns
| Type | Description |
|---|---|
| Task<byte[]> | The decrypted |
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 |
|---|---|---|
| string | data | The encrypted data string. |
| string | password | The password that was used to encrypt the data. |
Returns
| Type | Description |
|---|---|
| Task<string> | The decrypted string; |
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 |
|---|---|---|
| byte[] | data | The data to encrypt. |
Returns
| Type | Description |
|---|---|
| EncryptionResult | EncryptionResult containing the encrypted |
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 |
|---|---|---|
| byte[] | data | The data to encrypt. |
Returns
| Type | Description |
|---|---|
| Task<EncryptionResult> | EncryptionResult containing the encrypted |
EncryptWithPassword(byte[], string)
Encrypts data using a password.
Declaration
byte[] EncryptWithPassword(byte[] data, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | The data to encrypt. |
| string | password | The password used to derive the AES key. |
Returns
| Type | Description |
|---|---|
| byte[] | The encrypted data bytes. |
EncryptWithPassword(string, string)
Encrypts data using a password.
Declaration
string EncryptWithPassword(string data, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| string | data | The data to encrypt. |
| string | password | The password used to derive the AES key. |
Returns
| Type | Description |
|---|---|
| string | The encrypted data; |
EncryptWithPasswordAsync(byte[], string)
Encrypts data asynchronously using a password.
Declaration
Task<byte[]> EncryptWithPasswordAsync(byte[] data, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | The data to encrypt. |
| string | password | The password used to derive the AES key. |
Returns
| Type | Description |
|---|---|
| Task<byte[]> | The encrypted data bytes. |
EncryptWithPasswordAsync(string, string)
Encrypts data asynchronously using a password.
Declaration
Task<string> EncryptWithPasswordAsync(string data, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| string | data | The data to encrypt asynchronously. |
| string | password | The password used to derive the AES key. |
Returns
| Type | Description |
|---|---|
| Task<string> | The encrypted data. |