epic-crypt-gpg-aa
来自「EPIC IRC客户端。来源于IRCII客户端但做了很多性能和功能的优化。」· 代码 · 共 48 行
TXT
48 行
#!/bin/bash## This script demonstrates ascii armoring. It is rather complicated# because it uses the ascii armoring present in gpg, which wraps in# a way that is unusable for irc. One of the things that can be# done is to join all the cyphertext lines together, and reformat# them into a valid gpg message again at the other end.## Decryption is a little tricky. What we do is create a token ascii# armored gpg message, strip it of the message content, fill it in# with the reformatted message and pipe it back into gpg for# decryption.## Since the plaintext and cyphertext are read in non-newline binary# mode, echo -n is used.function encrypt { ( echo "$KEY" ; cat ) | gpg -ca -z 9 --batch --passphrase-fd 0 | ( while read && [ -n "$REPLY" ] ; do : ; done while read && [ -n "$REPLY" ] ; do [ -n "$LAST" ] && echo -n "$LAST " ; LAST="$REPLY" done )}function decrypt { read -a input ( echo x | gpg -ca --batch --passphrase-fd 0 | ( while read && [ -n "$REPLY" ] ; do echo "$REPLY" ; done while read && [ -n "$REPLY" ] ; do LAST="$REPLY" ; done echo for foo in "${input[@]}" ; do echo "$foo" ; done echo "$LAST" ) ) | ( echo "$KEY" ; cat ) | gpg -a --batch --passphrase-fd 0}proto="$1"shift 1read KEY TRASHcase "$proto" inencrypt) encrypt "$@" ;;decrypt) decrypt "$@" ;;*) echo `basename $0` "{encrypt|decrypt} < text" 1>&2 ;;esac
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?