summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2021-09-23 21:35:27 +0200
committerjonsykkel <jonrevold@gmail.com>2021-09-23 21:40:38 +0200
commitf2913d3bfd468398b474b90cabbbc0b80bc115eb (patch)
treefcedd03b5a83bcdda85b2494eb009ef814f5976a
parent9ac1068afe0396b0862c00f5a364241b2ff01bbb (diff)
downloadokeffa-f2913d3bfd468398b474b90cabbbc0b80bc115eb.tar.gz
ch8
-rwxr-xr-xprog/ch8.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/prog/ch8.sh b/prog/ch8.sh
index 5115942..e16764e 100755
--- a/prog/ch8.sh
+++ b/prog/ch8.sh
@@ -1,3 +1,15 @@
#!/bin/sh
-echo "?Q" | $1 4096 16
+ffa=$1
+bytes=256
+
+a=$(LC_ALL=C tr -dc "0-9A-F" </dev/random | dd bs=$bytes count=1 2>/dev/null)
+b=$(LC_ALL=C tr -dc "0-9A-F" </dev/random | dd bs=$bytes count=1 2>/dev/null)
+eq_bc="$a*$b"
+eq_ffa=".$a.$b*_#Q"
+ans_bc=$(bc -e "ibase=G;obase=G;$eq_bc" | tr -d '\\\n')
+ans_ffa=$(echo -n "$eq_ffa" | $ffa $(($bytes*2*8)) 16 | sed 's/^0*//')
+
+echo "bc $ans_bc"
+echo "ffa $ans_ffa"
+[ "$ans_bc" = "$ans_ffa" ] && echo "true" || echo "false"