コード例 #1
0
        public void Decrypt(Operation operation)
        {
            var encryptor = operation.SymmetricAlgorithm;

            var sourceFile = File.ReadAllBytes(operation.SourceFile);

            var header = sourceFile.Take(HeaderSize);

            var body = sourceFile.Skip(HeaderSize).Take(sourceFile.Length - HeaderSize).ToArray();

            var cryptoTransform = encryptor.CreateDecryptor(encryptor.Key, encryptor.IV);

            var resultArray = cryptoTransform.TransformFinalBlock(body, 0, body.Length);

            File.WriteAllBytes(operation.TargetFile, header.Concat(resultArray).ToArray());
        }
コード例 #2
0
 public void Encrypt(Operation operation)
 {
     var encHandler = _encryptors.Find(enc => enc.CanProcess(operation));
     encHandler.Encrypt(operation);
 }
コード例 #3
0
 public bool CanProcess(Operation operation)
 {
     return _encryptors.Any(enc => enc.CanProcess(operation));
 }
コード例 #4
0
 public bool CanProcess(Operation operation)
 {
     var returnValue = new FileInfo(operation.SourceFile).Extension.ToLowerInvariant() == ".bmp";
     return returnValue;
 }