aboutsummaryrefslogtreecommitdiff
path: root/envelope/gcdtest.sh
blob: be6ff7ed0c632c8a65dc955fc0ced9a160edd3f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash
function go() {
	keylen="$1"
	total="$2"
	for i in $(seq 1 "$total"); do
		./envelope -k "$keylen" 2>&1 | head -1 | cut -d' ' -f3 | outerr
	done | sort -n | uniq -c | head -1 | awk '{print $1}'
}

function percentage() {
	printf "%d bits, %d trials: %s%% 2's\n" "$1" "$2" "$(bc <<<"100*$(go $1 $2)/$2")"
}

percentage "$1" "$2"

#percentage 512 20
#percentage 700 20
#percentage 900 20
#percentage 1024 10
#percentage 1400 10
#percentage 2048 10