Class Symmetric
- Namespace
- SunamoShared.Crypting
- Assembly
- SunamoShared.dll
Symmetric encryption uses a single key to encrypt and decrypt. Both parties (encryptor and decryptor) must share the same secret key.
public class Symmetric
- Inheritance
-
Symmetric
- Inherited Members
- Extension Methods
Constructors
Symmetric(Provider, bool)
Instantiates a new symmetric encryption object using the specified provider. Automatically generates a random key. If useDefaultInitializationVector is true, uses the default IV; otherwise generates a random IV.
public Symmetric(Symmetric.Provider provider, bool isUsingDefaultInitializationVector)
Parameters
providerSymmetric.ProviderThe symmetric encryption provider to use.
isUsingDefaultInitializationVectorboolWhether to use the default initialization vector.
Properties
IntializationVector
Using the default Cipher Block Chaining (CBC) mode, all data blocks are processed using the value derived from the previous block; the first data block has no previous data block to use, so it needs an InitializationVector to feed the first block.
public DataCrypt IntializationVector { get; set; }
Property Value
Key
The key used to encrypt/decrypt data. Setting it also configures Min, Max and Step byte limits from the algorithm's legal key sizes.
public DataCrypt Key { get; set; }
Property Value
KeySizeBits
Key size in bits. Uses the default key size for any given provider; if you want to force a specific key size, set this property.
public int KeySizeBits { get; set; }
Property Value
KeySizeBytes
Key size in bytes. Uses the default key size for any given provider; if you want to force a specific key size, set this property.
public int KeySizeBytes { get; set; }
Property Value
Methods
Decrypt(DataCrypt)
Decrypts the specified data using preset key and preset initialization vector. Key and IV must be set before calling this method.
public DataCrypt Decrypt(DataCrypt encryptedDataCrypt)
Parameters
encryptedDataCryptDataCryptThe encrypted data to decrypt.
Returns
Decrypt(DataCrypt, DataCrypt)
Decrypts the specified data using provided key and preset initialization vector.
public DataCrypt Decrypt(DataCrypt encryptedDataCrypt, DataCrypt key)
Parameters
encryptedDataCryptDataCryptThe encrypted data to decrypt.
keyDataCryptThe decryption key to use.
Returns
Decrypt(Stream)
Decrypts the specified stream using preset key and preset initialization vector.
public DataCrypt Decrypt(Stream encryptedStream)
Parameters
encryptedStreamStreamThe encrypted stream to decrypt.
Returns
Decrypt(Stream, DataCrypt)
Decrypts the specified stream using provided key and preset initialization vector.
public DataCrypt Decrypt(Stream encryptedStream, DataCrypt key)
Parameters
Returns
Encrypt(DataCrypt)
Encrypts the specified DataCrypt using preset key and preset initialization vector.
public DataCrypt Encrypt(DataCrypt dataCrypt)
Parameters
dataCryptDataCryptThe data to encrypt.
Returns
Encrypt(DataCrypt, DataCrypt)
Encrypts the specified DataCrypt using provided key.
public DataCrypt Encrypt(DataCrypt dataCrypt, DataCrypt key)
Parameters
Returns
Encrypt(Stream)
Encrypts the specified stream to memory using preset key and preset initialization vector.
public DataCrypt Encrypt(Stream stream)
Parameters
streamStreamThe stream to encrypt.
Returns
Encrypt(Stream, DataCrypt)
Encrypts the stream to memory using specified key.
public DataCrypt Encrypt(Stream stream, DataCrypt key)
Parameters
Returns
Encrypt(Stream, DataCrypt, DataCrypt)
Encrypts the stream to memory using provided key and provided initialization vector.
public DataCrypt Encrypt(Stream stream, DataCrypt key, DataCrypt initVector)
Parameters
streamStreamThe stream to encrypt.
keyDataCryptThe encryption key to use.
initVectorDataCryptThe initialization vector to use.
Returns
RandomInitializationVector()
Generates a random Initialization Vector if one was not provided.
public DataCrypt RandomInitializationVector()
Returns
RandomKey()
Generates a random key if one was not provided.
public DataCrypt RandomKey()