From 9cbdd560c0d397f02138ef2d28a414d599a0c91d Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 5 Sep 2020 16:37:18 -0400 Subject: lib: add index * lib/b64.go (index): New function. --- lib/b64.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib') diff --git a/lib/b64.go b/lib/b64.go index bdf26c0..1fb45dd 100644 --- a/lib/b64.go +++ b/lib/b64.go @@ -23,6 +23,16 @@ func encode(b uint16) string { return string(b64_table[b]) } +// Return the index for a base64 character. +func index(c byte) uint32 { + for i := 0; i < 64; i++ { + if c == b64_table[i] { + return uint32(i) + } + } + return uint32(0) +} + // Strip space and newline characters from string. func stripSpaceChars(s string) string { ss := "" -- cgit v1.2.3