- commit
- 26949ae
- parent
- c66c6ae
- author
- Neale Pickett
- date
- 2024-03-28 15:59:36 -0600 MDT
Add bubblebabble
3 files changed,
+83,
-4
M
Makefile
+1,
-0
1@@ -17,6 +17,7 @@ TARGETS += entropy
2 TARGETS += freq
3 TARGETS += histogram
4 TARGETS += printy
5+TARGETS += bubblebabble
6
7 SCRIPTS += octets
8
+29,
-4
1@@ -313,10 +313,35 @@ Reads the first number of each line, and prints a histogram.
2 0a ◙ # 1
3 41 A ######## 8
4 61 a ################ 16
5- $ echo 'aaaaaaaaAAAAAAAAaaaaaaaa' | freq | histogram -d 4
6- 0a ◙ 1
7- 41 A ## 8
8- 61 a #### 16
9+ $ echo aaaaaabcccc | freq | histogram
10+ 0a ◙ # 1
11+ 61 a ###### 6
12+ 62 b # 1
13+ 63 c #### 4
14+ $ echo aaaaaabcccc | freq | histogram | sort -nk 4
15+ 0a ◙ # 1
16+ 62 b # 1
17+ 63 c #### 4
18+ 61 a ###### 6
19+
20+
21+## bubblebabble: print bubblebabble digest of input
22+
23+Prints a [bubblebabble digest](https://web.mit.edu/kenta/www/one/bubblebabble/spec/jrtrjwzi/draft-huima-01.txt)
24+of the input.
25+
26+This is a *digest*, not a *hash*:
27+it can be reversed.
28+If you write `unbubblebabble` before I do,
29+please send it to me :)
30+
31+ $ printf '' | bubblebabble
32+ xexax
33+ $ printf 1234567890 | bubblebabble
34+ xesef-disof-gytuf-katof-movif-baxux
35+ $ printf Pineapple | bubblebabble
36+ xigak-nyryk-humil-bosek-sonax
37+
38
39
40 Example Recipes
+53,
-0
1@@ -0,0 +1,53 @@
2+#include <stdio.h>
3+
4+/** Compute bubble babble for input buffer.
5+ *
6+ * The generated output will be of length 6*((inlen/2)+1), including the
7+ * trailing NULL.
8+ *
9+ * Test vectors:
10+ * `' (empty string) `xexax'
11+ * `1234567890' `xesef-disof-gytuf-katof-movif-baxux'
12+ * `Pineapple' `xigak-nyryk-humil-bosek-sonax'
13+ */
14+static char const consonants[] = "bcdfghklmnprstvz";
15+static char const vowels[] = "aeiouy";
16+
17+int
18+main(int argc, char *argv[])
19+{
20+ int seed = 1;
21+
22+ putchar('x');
23+ while (1) {
24+ int c;
25+
26+ c = getchar();
27+ if (EOF == c) {
28+ putchar(vowels[seed % 6]);
29+ putchar('x');
30+ putchar(vowels[seed / 6]);
31+ break;
32+ }
33+
34+ putchar(vowels[(((c >> 6) & 3) + seed) % 6]);
35+ putchar(consonants[(c >> 2) & 15]);
36+ putchar(vowels[((c & 3) + (seed / 6)) % 6]);
37+
38+ seed = (seed * 5) + (c * 7);
39+ c = getchar();
40+ seed = (seed + c) % 36;
41+
42+ if (EOF == c) {
43+ break;
44+ }
45+ putchar(consonants[(c >> 4) & 15]);
46+ putchar('-');
47+ putchar(consonants[c & 15]);
48+ }
49+
50+ putchar('x');
51+ putchar('\n');
52+
53+ return 0;
54+}