__main__.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:sagecipher 作者: p-sherratt 项目源码 文件源码
def decrypt_to_fifo(_input, _output, _mode, _force, text=None):
    def write_to_fifo(notifier):
        st = os.stat(_output)
        if not stat.S_ISFIFO(st.st_mode):
            raise click.ClickException('%s is not a FIFO!' % _output)
        if (st.st_mode & 0o777 != _mode):
            raise click.ClickException('mode has changed on %s!' % _output)

        if _input != '-':
            f_in = open(_input, 'rb')
            text = f_in.read()
            f_in.close()

        try:
            f = open(_output, 'w')
            text = decrypt_string(text)
            f.write(text)
            f.close()
        except IOError:
            pass
        finally:
            text = str(0x00) * len(text)

    wm = pyinotify.WatchManager()
    notifier = pyinotify.Notifier(wm, pyinotify.ProcessEvent)
    wm.add_watch(_output, pyinotify.IN_CLOSE_NOWRITE)
    notifier.loop(callback=write_to_fifo)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号