コード例 #1
0
 public Command Initialize(string[] args)
 {
     if (args.Length == 4)
     {
         fileService  = new FileService();
         consoleUtils = new ConsoleUtils();
         Console.WriteLine("You need a passphrase to unlock a private key.");
         Console.Write("Enter a passphrase: ");
         privateKey = fileService.GetPrivateKeyFromFile(args[1], consoleUtils.GetPassword());
         if (File.Exists(args[2]))
         {
             cipherData = File.ReadAllBytes(args[2]);
         }
         else
         {
             throw new ArgumentException();
         }
         pathToDecryptedData = args[3];
         rsaes_oaep          = new RSAES_OAEP();
         hash        = new SHA512CryptoServiceProvider();
         initialized = true;
         return(this);
     }
     else
     {
         throw new ArgumentException();
     }
 }
コード例 #2
0
 public Command Initialize(string[] args)
 {
     if (args.Length == 4)
     {
         try
         {
             fileService = new FileService();
             publicKey   = fileService.GetPublicKeyFromFile(args[1]);
             if (File.Exists(args[2]))
             {
                 plainText = File.ReadAllBytes(args[2]);
             }
             else
             {
                 throw new ArgumentException();
             }
             pathToCipherText = args[3];
             rsaes_oaep       = new RSAES_OAEP();
             hash             = new SHA512CryptoServiceProvider();
             initialized      = true;
             return(this);
         } catch (Exception)
         {
             throw new ArgumentException();
         }
     }
     else
     {
         throw new ArgumentException();
     }
 }
コード例 #3
0
 public void setUp()
 {
     oaep         = new RSAES_OAEP();
     hash         = new SHA512CryptoServiceProvider();
     keyGenerator = new KeyGenerator();
 }