title: Golang hex encoding
body: <p>I'm attempting to recreate a PKCS #5 Padding algorithm I've found written in python.  </p>
  
  <p>The main line I'm struggling to recreate is this</p>
  
  <pre><code>return data + (chr(pad_count) * pad_count).encode('utf-8')
  </code></pre>
  
  <p>which essentially repeats pad_count (an integer, between 1 and 16), as a char, between 1 and 16 times. I'm having trouble getting a similar result in Go. </p>
  
  <p>For example, pad_count of 11 will return the string</p>
  
  <pre><code>\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b
  </code></pre>
  
  <p>The closeset I've come is this:</p>
  
  <pre><code>b := make([]byte, 2)
  binary.LittleEndian.PutUint16(b, uint16(padCount))
  fmt.Println("Pad: ", padCount, "Hex: ", hex.EncodeToString(b))
  </code></pre>
  
  <p>which will return:</p>
  
  <pre><code>Pad: 11 Hex: 0b00
  </code></pre>
  
  <p>This is pretty close, and obviously I could take a substring, and add the \x myself, but is there a better way to go about this?  Also if I substring, I feel there is no guarantee that would work for all the combinations.   </p>