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 SourceDecrypt(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 |
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 |
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 |
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. |
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 |
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; |
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 |
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 |
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. |
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; |
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. |
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. |