-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathotp-ascii
61 lines (47 loc) · 1.88 KB
/
otp-ascii
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Name: otp-ascii, Version: 1.3.1
# Discription: One-time Pad ASCII Printable Characters.
# Author: Nikolas Britton
# E-mail: [email protected] (caesar, 11)
# Copyright 2021 Nikolas Britton, Apache 2.0 License
# Notes: Imagemagick is a dependency.
test -x /usr/local/bin/convert || {
echo "Imagemagick's convert utility is a dependency, please install it first.";
exit 1;
}
timestamp=$(date +%s);
function horizontal-legend () {
printf 'ab#';
for ((index_ab=33;index_ab<127;index_ab++)) do
printf "\\$(printf %03o "${index_ab}")";
done;
echo;
printf 'cd#';
for ((index_cd=126;index_cd>32;index_cd--)) do
printf "\\$(printf %03o "${index_cd}")";
done;
echo;
}
function otp-ascii () {
horizontal-legend;
printf '#%.0s' {1..97};
echo;
for ((index_ac=33,index_bd=126,switch=0;index_ac<127;index_ac++,index_bd--)) do
printf "\\$(printf %03o "${index_ac}")";
printf "\\$(printf %03o "${index_bd}")";
printf '#';
LC_CTYPE=C < /dev/urandom tr -cd [:graph:] | tr -d '\n' | fold -w 94 | head -n 1;
done;
}
echo > otp-ascii-${timestamp}.txt;
for k in $(seq -w 0 20); do
printf "KEY$k " >> otp-ascii-${timestamp}.txt;
LC_CTYPE=C < /dev/urandom tr -cd [:graph:] | tr -d '\n' | fold -w 94 | head -n 1 | sed -e 's/\(.\)/\1 /g' >> otp-ascii-${timestamp}.txt;
done;
printf "SHA01 " >> otp-ascii-${timestamp}.txt;
shasum -a 512256 otp-ascii-${timestamp}.txt >> otp-ascii-${timestamp}.txt;
otp-ascii | sed -e 's/\(.\)/\1 /g' >> otp-ascii-${timestamp}.txt;
printf "SHA02 " >> otp-ascii-${timestamp}.txt;
shasum -a 512256 otp-ascii-${timestamp}.txt >> otp-ascii-${timestamp}.txt;
convert -density 600 -units pixelsperinch -size 12000x12000 xc:white -font "Monaco" -pointsize 8 -fill black -annotate +15+15 "@otp-ascii-${timestamp}.txt" -trim +repage otp-ascii-${timestamp}.png;
#rm otp-ascii-${timestamp}.txt;