public byte[] Generate(EncryptionKeyInput input)
        {
            var seed = $"{input.FullName}|{input.DateOfBirth}|{input.SocialSecurityNumber}|{input.PassPhrase}";

            var seedBinary = Encoding.ASCII.GetBytes(seed);

            using (var sha1 = SHA256.Create())
                return(sha1.ComputeHash(seedBinary));
        }
Beispiel #2
0
 /// <summary>
 /// Creates an IFileEncryptor based on the given encryption key input structure.
 /// </summary>
 /// <param name="encryptionKeyInput">Encryption key input structure.</param>
 /// <param name="vaultName">Vault name.</param>
 /// <returns>IFileEncryptor instance.</returns>
 public static IFileEncryptor CreateFileEncryptor(
     EncryptionKeyInput encryptionKeyInput, string vaultName)
 {
     return(new FileEncryptor(
                AppContainer.SymmetricEncryptor,
                AppContainer.EncryptionKeyGenerator,
                AppContainer.ConfigurationProvider,
                AppContainer.FileNameManager,
                encryptionKeyInput,
                vaultName));
 }
Beispiel #3
0
        internal FileEncryptor(
            ISymmetricEncryptor symmetricEncryptor,
            IEncryptionKeyGenerator encryptionKeyGenerator,
            IConfigurationProvider configurationProvider,
            IFileNameManager fileNameManager,
            EncryptionKeyInput encryptionKeyInput,
            string vaultName)
        {
            var key = encryptionKeyGenerator.Generate(encryptionKeyInput);

            this.parameters = new SymmetricEncryptionParameters
            {
                Algorithm = AlgorithmType.Aes,
                Mode      = CipherMode.CBC,
                Padding   = PaddingMode.PKCS7,
                Key       = key
            };

            this.symmetricEncryptor    = symmetricEncryptor;
            this.configurationProvider = configurationProvider;
            this.fileNameManager       = fileNameManager;
            this.vaultName             = vaultName;
        }