This commit is contained in:
Matthieu Dubuget committed 2026-11-22 18:19:16 +01:00
commit 42e5e3321a
12 files changed
+593

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
let decode s =
let value = function
| 'a' .. 'z' as c -> Char.code c - Char.code 'a'
| 'A' .. 'Z' as c -> Char.code c - Char.code 'A'
| c -> Char.code c - Char.code '2' + 26
in
let buf = Buffer.create 32 in
let acc = ref 0 and bits = ref 0 in
String.iter
(fun c ->
acc := (!acc lsl 5) lor value c;
bits := !bits + 5;
if !bits >= 8 then begin
bits := !bits - 8;
Buffer.add_char buf (Char.chr ((!acc lsr !bits) land 0xff))
end)
s;
Buffer.contents buf