예제 #1
0
        public static void Encrypt(Stream input, Stream output, string password, string filename = null, Action <double> progress = null, Func <bool> isCanceled = null)
        {
            var derivationSettings = PasswordDerivationSettings.Create();
            var secretKey          = Hasher.CreateAesKeyFromPassword(password, derivationSettings.Salt, derivationSettings.Iterations);
            var parameter          = new EncryptInternalParameter
            {
                Filename = filename,
                PasswordDerivationSettings         = derivationSettings,
                EllipticCurveEncryptionInformation = null,
                Progress   = progress,
                IsCanceled = isCanceled,
            };

            EncryptInternal(input, output, secretKey, parameter);
        }
예제 #2
0
        public static void Encrypt(string inputPath, string outputPath, string password, string filename = null, Action <double> progress = null, Func <bool> isCanceled = null)
        {
            var derivationSettings = PasswordDerivationSettings.Create();
            var secretKey          = Hasher.CreateAesKeyFromPassword(password, derivationSettings.Salt, derivationSettings.Iterations);
            var parameter          = new EncryptInternalParameter
            {
                Filename = filename,
                PasswordDerivationSettings         = derivationSettings,
                EllipticCurveEncryptionInformation = null,
                Progress   = progress,
                IsCanceled = isCanceled,
            };

            using (var input = File.OpenRead(inputPath))
                using (var output = File.Open(outputPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
                {
                    EncryptInternal(input, output, secretKey, parameter);
                }
        }