Matasano BASE64

40 views
Skip to first unread message

Mark Champine

unread,
Aug 15, 2014, 4:25:07 PM8/15/14
to boston-...@googlegroups.com
Restart!

After reflecting for a bit, I took an entirely new approach to the b64 encoder.

The basic idea now is to use for loops to generate hashmaps for converting hex chars to 4-bit patterns, and from 6-bit patterns to B64 encoding chars. After that, all that was left for the simple encoder was to change the chunk size of the bit sequence from 4 to 6 using the partition function. So: hex->4bit->6bit->b64chars  This seems rather brute-force but it's dead simple and should be quite fast. It also avoids all the Java interop conversion calls.

After that, I tackled padding. My version of this seems a bit clunky and there are probably prettier ways of doing it.  Any takers?

See https://github.com/boston-clojure/cryptfun/blob/master/src/cryptfun/matasanob64.clj

What do you think of my approach? Did any of you finish your own versions?  Please share!

Mark

Michael Fogleman

unread,
Aug 15, 2014, 4:58:49 PM8/15/14
to boston-...@googlegroups.com
Hi Mark,

Thanks for your help last night. I'll take a look at your code, and I hope to keep working on the Challenges.

You said you're avoiding the Java interop calls now-- if you keep working on these challenges, do you think you'll keep that strategy?

Mark Champine

unread,
Aug 15, 2014, 5:43:44 PM8/15/14
to boston-...@googlegroups.com
>You said you're avoiding the Java interop calls now-- if you keep working on these challenges, do you think you'll keep that strategy?

Nope. Already using parseInt and toHexString in the next challenge. I won't just wrap some complete solution (e.g. wrap a java b64) but I think it's fine to use low level library routines like these and still stay within the spirit of the challenges.

M.
Reply all
Reply to author
Forward
0 new messages