示例#1
0
        public long PerformEncryption(CommonOptions options, IOutputHandler outputHandler, EncryptOperation o, byte[] key)
        {
            outputHandler.WriteVerbose("\t{0} => ", o.RelFileName);

            var result = FileEncrypter.EncryptFile(options.DestinationDir, o, key);

            if (result.HasResult)
            {
                outputHandler.WriteVerboseLine(o.EncFileName);
                return(result.Result.Item2);
            }

            outputHandler.WriteVerboseOrNormalLine("\t{0} => Failed to encrypt file! ({1})", "Failed to encrypt file! ({1})", o.RelFileName, result.ErrorMessage);
            return(0);
        }
示例#2
0
        public static long PerformDecryption(CommonOptions options, IOutputHandler outputHandler, string file, byte[] key)
        {
            outputHandler.WriteVerbose("{0} => ", file.Replace(options.SourceDir, "").TrimStart(new[] { Path.DirectorySeparatorChar }));

            var result = FileEncrypter.DecryptFile(options.DestinationDir, file, key);

            if (result.HasResult)
            {
                outputHandler.WriteVerboseLine(result.Result.Item1.Replace(options.DestinationDir, "").TrimStart(new[] { Path.DirectorySeparatorChar }));
                return(result.Result.Item2);
            }

            outputHandler.WriteLine("Failed to decrypt file! ({0})", result.ErrorMessage);
            return(0);
        }
示例#3
0
        public static void Generate(IOutputHandler outputHandler)
        {
            var key = FileEncrypter.GenerateKey();

            outputHandler.WriteLine("Generated key: {0}", Convert.ToBase64String(key));
        }