弱弱问下 GO 密文输入有什么可以实现。。。

galbies · · 2391 次点击
`main`第一行再加一句 `fmt.Print("Input password:")`
#2
更多评论
仅限Linux: ```go package main func main() { pwd = new(string) terminalEcho(false) // Hide input fmt.Scanln(pwd) terminalEcho(true) fmt.Println(pwd) } func terminalEcho(show bool) { // Enable or disable echoing terminal input. This is useful specifically for // when users enter passwords. // calling terminalEcho(true) turns on echoing (normal mode) // calling terminalEcho(false) hides terminal input. var termios = &syscall.Termios{} var fd = os.Stdout.Fd() if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, syscall.TCGETS, uintptr(unsafe.Pointer(termios))); err != 0 { return } if show { termios.Lflag |= syscall.ECHO } else { termios.Lflag &^= syscall.ECHO } if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TCSETS), uintptr(unsafe.Pointer(termios))); err != 0 { return } } ```
#1
感谢。。。。。。。。
#3