Go中的getpasswd功能?功能、Go、getpasswd

由网友(揣着美钞逛小卖部!)分享简介:情况:我想从 stdin 控制台获取密码条目 - 不回显用户键入的内容.Go 中是否有与 getpasswd 功能相媲美的功能?I want to get a password entry from the stdin console - without echoing what the user types. I...

情况:

我想从 stdin 控制台获取密码条目 - 不回显用户键入的内容.Go 中是否有与 getpasswd 功能相媲美的功能?

I want to get a password entry from the stdin console - without echoing what the user types. Is there something comparable to getpasswd functionality in Go?

我尝试了什么:

我尝试使用 syscall.Read,但它会回显输入的内容.

I tried using syscall.Read, but it echoes what is typed.

推荐答案

你可以通过执行 stty -echo 来关闭 echo ,然后在阅读后执行 stty echo在密码中将其重新打开

you can do this by execing stty -echo to turn off echo and then stty echo after reading in the password to turn it back on

阅读全文

相关推荐

最新文章