使用Haskell捕获输入和直接输出到台式机?
我有一个程序,可以有效地将键上的键随机重新映射,因此每个程序都对应于与通常产生的不同输出。
我的问题是,我仅捕获输入程序运行的终端的键,同样仅输出到同一终端。我想实现的目标是捕获和转换桌面上的所有击键,并在程序运行时输出最初输入的转换键。
这是我的主要循环。
main = do
hSetBuffering stdin NoBuffering
hSetEcho stdout False
s <- shuffle keys
displayKeys s
putStrLn ""
let
typeLoop = do
c <- getChar
let shuf_tuples = zip keys s
new_key = reMap c shuf_tuples
putChar $ fromMaybe ' ' new_key
typeLoop
typeLoop
该程序旨在作为键入安全信息(例如密码)的原型,因此在解决方案和现有实施中都可以进行安全考虑。
我正在使用Ubuntu 20.04,并且更喜欢需要包装最少的解决方案(如果可能的话)。也不会介意完全便携式解决方案,因为它可能会帮助其他人。如果我能提出另一个偏好:我正在学习HASKELL,即使它牺牲了可移植性,也会赞成一种“从头开始”的方法。
I have a program which effectively shuffles the keys on the keyboard, remapping them randomly so each one corresponds to a different output than it normally produces.
My issue is that I am only capturing keys inputted to the terminal the program runs in, and likewise only outputting to that same terminal. What I would like to achieve is capturing and transforming all keystrokes across the desktop and outputting the transformed key where it was originally input while the program runs.
Here is my main loop.
main = do
hSetBuffering stdin NoBuffering
hSetEcho stdout False
s <- shuffle keys
displayKeys s
putStrLn ""
let
typeLoop = do
c <- getChar
let shuf_tuples = zip keys s
new_key = reMap c shuf_tuples
putChar $ fromMaybe ' ' new_key
typeLoop
typeLoop
This program is intended as a prototype for typing secure information like passwords so security considerations both in the solution and existing implementation are appreciated.
I am using Ubuntu 20.04 and would prefer the solutions requiring the least packages (if possible). Would not mind fully portable solutions either as it may help other people. If I can put in another preference: I am learning Haskell and would favor a 'from scratch' approach even if it sacrifices portability.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论