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()); }
public void Encrypt(Operation operation) { var encHandler = _encryptors.Find(enc => enc.CanProcess(operation)); encHandler.Encrypt(operation); }
public bool CanProcess(Operation operation) { return _encryptors.Any(enc => enc.CanProcess(operation)); }
public bool CanProcess(Operation operation) { var returnValue = new FileInfo(operation.SourceFile).Extension.ToLowerInvariant() == ".bmp"; return returnValue; }