title: How can I directly work with bits in Clojure?
body: <p>I began working through the first problem set over at <a href="https://cryptopals.com" rel="nofollow noreferrer">https://cryptopals.com</a> the other day. I'm trying to learn Clojure simultaneously, so I figured I'd implement all of the exercises in Clojure. These exercises are for learning purposes of course, but I'm going out of my way to not use any libraries besides clojure.core and the Java standard library.
  The first exercise asks you to write code that takes in a string encoded in hexadecimal and spit out a string encoded in base64. The algorithm for doing this is fairly straightforward:</p>
  
  <ol>
  <li>Get the byte associated with each couplet of hex digits (for example, the hex <code>49</code> becomes <code>01001001</code>).</li>
  <li>Once all bytes for the hex string have been retrieved, turn the list of bytes into a sequence of individual bits.</li>
  <li>For every 6 bits, return a base64 character (they're all represented as units of 6 bits).</li>
  </ol>
  
  <p>I'm having trouble actually representing/working-with bits and bytes in Clojure (operating on raw bytes is one of the requirements of the exercise). I know I can do <code>byte-array</code> on the initial hex values and get back an array of bytes, but how do I access the raw bits so that I can translate from a series of bytes into a base64 encoded string?
  Any help or direction would be greatly appreciated.</p>