Show / Hide Table of Contents

Class Symmetric

Utility class for performing simple symmetric encryption and decryption based upon values in the ConfigFile.Security.Cryptography.

The encrypted data has an encryption header in this general format: Version | IV | EncryptedData | Signature

Version 1 uses AES256 (in CBC mode) and HMACSHA256 as the encryption and signature algorithms.

Inheritance
object
Symmetric
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
Namespace: SuperOffice.Security.Cryptography
Assembly: SoCore.dll
Syntax
public sealed class Symmetric

Constructors

Symmetric()

Utility class for performing simple symmetric encryption and decryption based upon values in the ConfigFile.Security.Cryptography.

The encrypted data has an encryption header in this general format: Version | IV | EncryptedData | Signature

Version 1 uses AES256 (in CBC mode) and HMACSHA256 as the encryption and signature algorithms.

Declaration
public Symmetric()

Methods

Decrypt(string)

Decrypts the Base64 encoded string and return it as a clear-text string.

Declaration
public static string Decrypt(string text)
Parameters
Type Name Description
string text

Base64 encoded encrypted string.

Returns
Type Description
string

Decrypted string

Remarks

The signature of the data is verified before the data is decrypted.

DecryptBytes(string)

Decrypts the Base64 encoded string and return it as a byte array (e.g. byte[]).

Declaration
public static byte[] DecryptBytes(string text)
Parameters
Type Name Description
string text

Base64 encoded encrypted string.

Returns
Type Description
byte[]

Decrypted byte array (e.g. byte[]).

Remarks

The signature of the data is verified before the data is decrypted.

DecryptUTF8(string)

Decrypts the base64 encoded version. Throws SoInvalidSignatureException if the signature is invalid.

Declaration
public static string DecryptUTF8(string text)
Parameters
Type Name Description
string text
Returns
Type Description
string

Encrypt(string)

Encrypts the string and return it as a Base64 encoded encrypted string.

Declaration
public static string Encrypt(string text)
Parameters
Type Name Description
string text

Text to encrypt.

Returns
Type Description
string

Encrypted Base64 encoded string

Remarks

The data is encrypted and signed.

EncryptBytes(byte[])

Encrypts the byte array (e.g. byte[]) and return it as a Base64 encoded encrypted string.

Declaration
public static string EncryptBytes(byte[] bytes)
Parameters
Type Name Description
byte[] bytes

byte array (e.g. byte[]) to encrypt.

Returns
Type Description
string

Encrypted Base64 encoded string

Remarks

The data is encrypted and signed.

EncryptUTF8(string)

Utility class for performing simple symmetric encryption and decryption based upon values in the ConfigFile.Security.Cryptography.

The encrypted data has an encryption header in this general format: Version | IV | EncryptedData | Signature

Version 1 uses AES256 (in CBC mode) and HMACSHA256 as the encryption and signature algorithms.

Declaration
public static string EncryptUTF8(string text)
Parameters
Type Name Description
string text
Returns
Type Description
string

GenerateEncryptionKeyAsBase64()

Generate a new key for usage on the current encryption algorithm.

Declaration
public static string GenerateEncryptionKeyAsBase64()
Returns
Type Description
string

A base64-encoded version of the generated key

GenerateSigningKeyAsBase64()

Generate a new "secret" which is used when signing the encrypted data.

Declaration
public static string GenerateSigningKeyAsBase64()
Returns
Type Description
string

A base64-encoded version of the generated secret/signing key

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
ObjectExtensions.AssignByReflection<T>(T, T)
ObjectExtensions.GraphCopy<T>(T)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top