title: Troubles converting String to Byte for "RSA" encryption( Java)
body: <p>I would like to create few java function to add in a android studio application.The purpose of those function is  begin able to send encrypted message with RSA encryption.</p>
  
  <p>I first generate both keys. Then I use the public one to encrypt my message and it works. Then , I translate the encrypted message from byte[] to String() because I would like to send the message by SMS. 
  All those parts works. Then i try to reuse the SMS that i should receive in the SMS but it doesn't work.I obtain the following mistake  :</p>
  
  <pre><code>"javax.crypto.BadPaddingException: Decryption error" &lt;br/&gt;
  </code></pre>
  
  <p>in this line:<br/>
       "descryptedData = cipher.doFinal(decrypt); " // (cf code below) </p>
  
  <p>i use <i>.toString()</i> function to translate the message encrypted from bytes to String. If I skip the part where I translate from bytes to String for sending the SMS and from String to bytes for decrypt the data, it works perfectly.</p>
  
  <p>Here is the part of the code that could interest you : </p>
  
  <pre><code>PrivateKey privateKey = null;
  privateKey = appMob.getPrivKey(keys[1]); //return the privatekey      
  System.out.println("\n--- Decryption started--- \n");
  byte[] descryptedData = null;
  
  try{
      byte[] decrypt = smsWithCryptedData.getBytes("UTF-8");
      Cipher cipher = Cipher.getInstance("RSA");
      cipher.init(Cipher.DECRYPT_MODE,privateKey);
      descryptedData = cipher.doFinal(decrypt);
      String smsFinal = new String(descryptedData);
  
      System.out.println("decrypt \n smsFinal");
  
  
  }catch(Exception e)
      {
          e.printStackTrace();
  
      }
  </code></pre>
  
  <p>I suppose that the error comes from converting String to byte and byte to string but i don't know how to solve it. Does somebody have an idea ? </p>