title: Convert Hex string to Byte Array for RSA Decryption
body: <p>I have a hex string after RSA encryption. When I convert it to a byte[], the RSA decryption gives javax.crypto.BadPaddingException: Blocktype mismatch: 0</p>
  
  <p>I am using this method for conversion (got it on Stack overflow itself)</p>
  
  <pre><code>public static byte[] hexStringToByteArray(String data) {
      int k = 0;
      byte[] results = new byte[data.length() / 2];
      for (int i = 0; i &lt; data.length();) {
          results[k] = (byte) (Character.digit(data.charAt(i++), 16) &lt;&lt; 4);
          results[k] += (byte) (Character.digit(data.charAt(i++), 16));
          k++;
      }
      return results;
  }
  </code></pre>
  
  <p>Any suggestions please.</p>