Skip to content

Commit 6feae0b

Browse files
IceflowRElove-linger
authored andcommitted
fix: support utf-8 passphrases in askpass (#2293)
(cherry picked from commit f5adad5)
1 parent 0b10709 commit 6feae0b

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎src/Views/Askpass.axaml.cs‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System;
2+
using System.Text;
3+
using System.Security.Cryptography;
24

35
using Avalonia.Input;
46
using Avalonia.Interactivity;
@@ -27,7 +29,19 @@ private void CloseWindow(object _1, RoutedEventArgs _2)
2729
private void EnterPassword(object _1, RoutedEventArgs _2)
2830
{
2931
var passphrase = TxtPassphrase.Text ?? string.Empty;
30-
Console.Out.WriteLine(passphrase);
32+
byte[] passBytes = Encoding.UTF8.GetBytes(passphrase);
33+
try
34+
{
35+
var outStream = Console.OpenStandardOutput();
36+
outStream.Write(passBytes, 0, passBytes.Length);
37+
outStream.WriteByte((byte)'\n');
38+
outStream.Flush();
39+
}
40+
finally
41+
{
42+
CryptographicOperations.ZeroMemory(passBytes);
43+
TxtPassphrase.Text = string.Empty;
44+
}
3145
App.Quit(0);
3246
}
3347
}

0 commit comments

Comments
 (0)