コード例 #1
0
ファイル: Password.cs プロジェクト: samuel-lucas6/Kryptor
 private static byte[] UseKeyfile(byte[] passwordBytes, string keyfilePath)
 {
     try
     {
         byte[] keyfileBytes = Keyfiles.ReadKeyfile(keyfilePath);
         return(passwordBytes == null ? keyfileBytes : CombineKeyfileAndPassword(passwordBytes, keyfileBytes));
     }
     catch (Exception ex) when(ExceptionFilters.FileAccess(ex))
     {
         DisplayMessage.Exception(ex.GetType().Name, "Unable to read keyfile. The keyfile has not been used.");
         return(passwordBytes);
     }
 }
コード例 #2
0
 private static byte[] GetKeyfileBytes(byte[] passwordBytes, string keyfilePath)
 {
     if (!string.IsNullOrEmpty(keyfilePath))
     {
         byte[] keyfileBytes = Keyfiles.ReadKeyfile(keyfilePath);
         if (keyfileBytes != null)
         {
             MemoryEncryption.DecryptByteArray(ref passwordBytes);
             // Combine password and keyfile bytes
             passwordBytes = HashingAlgorithms.Blake2(passwordBytes, keyfileBytes);
             MemoryEncryption.EncryptByteArray(ref passwordBytes);
             Utilities.ZeroArray(keyfileBytes);
         }
     }
     return(passwordBytes);
 }
コード例 #3
0
 private static byte[] KeyfileAsPassword(string keyfilePath)
 {
     // If only a keyfile was selected, use the keyfile bytes as the password
     byte[] passwordBytes = Keyfiles.ReadKeyfile(keyfilePath);
     return(HashPasswordBytes(passwordBytes));
 }