1 个不稳定版本
0.1.0 | 2020年3月7日 |
---|
#10 in #knife
22KB
233 行
Krypt
Krypt是终端中用于编码、解码和散列的多功能工具。
安装
使用cargo
cargo install krypt
从源代码构建
要求
- Rust (1.41稳定版)
- cargo
git clone [email protected]:Stupremee/krypt
cd krypt
# Just build the binary
cargo build --release
# Install krypt
cargo install --path .
使用方法
散列
# hash stdin input and output hex representation
$ echo -n "hello world" | krypt -f hex hash sha256
> b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
# output raw bytes to
# -f raw is optional because the default format is raw
$ echo -n "hello world" | krypt -f raw hash sha256 | xxd
> 00000000: b94d 27b9 934d 3e08 a52e 52d7 da7d abfa .M'..M>...R..}..
> 00000010: c484 efe3 7a53 80ee 9088 f7ac e2ef cde9 ....zS..........
# output in hexdump format using hexyl
$ echo -n "hello world" | krypt -f hexdump hash sha256
> ┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐
> │00000000│ b9 4d 27 b9 93 4d 3e 08 ┊ a5 2e 52 d7 da 7d ab fa │×M'××M>•┊×.R××}××│
> │00000010│ c4 84 ef e3 7a 53 80 ee ┊ 90 88 f7 ac e2 ef cd e9 │××××zS××┊××××××××│
> └────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘
# use file as input
$ echo -n "hello world" > your_file
$ krypt -i your_file -f hex hash sha256
> b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
# hash raw bytes
$ echo -n "\xff" | krypt -f hex hash sha256
> a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89
# use hex encoded data as input
$ echo "0xff" | krypt --hex-input -f hex hash sha256
> a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89
# works also with files
$ echo "0xff" > your_file
$ krypt --hex-input -i your_file -f hex hash sha256
> a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89
编码
# encode string to bsae64
$ echo "hello!" | krypt encode base64
> aGVsbG8hCg==
# decode data
$ echo "aGVsbG8hCg==" | krypt encode -d base64
> hello!
# encode raw bytes (the 0A is the newline character)
$ echo "\xaa\xbb\xcc" > foo
$ krypt -i foo encode hex
> AABBCC0A
许可证
本项目采用GPLv3许可证。
依赖项
~7–15MB
~182K SLoC