public static Encryptor <T> CreateEncryptorWithGivenSalt <T>( [NotNull] string secretKey, [NotNull] byte[] salt, EncryptionOptions options = DefaultOptions) where T : SymmetricAlgorithm { Contract.Requires <ArgumentNullException>(secretKey != null); Contract.Requires <ArgumentNullException>(salt != null); int keySize; using (T algorithm = SymmetricTransformer <T> .CreateAlgorithm()) { keySize = algorithm.KeySize; } return(new Encryptor <T>( DeriveEncryptionKeyFromPasswordAndSalt(secretKey, keySize, salt), salt, options)); }
public static Encryptor <T> CreateEncryptor <T>( [NotNull] string secretKey, out byte[] randomSalt, EncryptionOptions options = DefaultOptions) where T : SymmetricAlgorithm { Contract.Requires <ArgumentNullException>(secretKey != null); int keySize, blockSize; using (T algorithm = SymmetricTransformer <T> .CreateAlgorithm()) { keySize = algorithm.KeySize; blockSize = algorithm.BlockSize; } return(new Encryptor <T>( DeriveEncryptionKeyAndSaltFromPassword(secretKey, keySize, blockSize, out randomSalt), randomSalt, options)); }