下面的示例将读取用户的密码,但也会以纯文本的形式回显它,有什么方法可以解决这个问题吗?
Future<String> promptPassword() {
var completer = new Completer<String>();
var stream = new StringInputStream(stdin);
stdout.writeString("Warning: Password will be displayed here until I find a better way to do this.\n");
stdout.writeString("Watch your back...\n");
stdout.writeString("GitHub password for $gituser: ");
stream.onLine = () {
var str = stream.readLine();
stdin.close();
completer.complete(str);
};
return completer.future;
}发布于 2013-01-30 05:05:11
在将tty控件添加到dart:io之前,这是不可能的。在此期间,我建议:
stty -echo
dart ./password.dart
stty echo我在这里打开了一个bug:https://code.google.com/p/dart/issues/detail?id=8190
https://stackoverflow.com/questions/14591347
复制相似问题