title: RSA Encryption/Decryption Convert Byte[] to String and Vice Versa
body: <p>I am workin on a Rsa encrypt/decrypt application on android.I create and save my public/private key to sharedpreferences.I am reading them and using for encrypt/decrypt with this code block:</p>
  
  <pre><code>public String RSADecrypt(byte[] encryptedBytes) throws NoSuchAlgorithmException, NoSuchPaddingException,InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidKeySpecException, UnsupportedEncodingException {
  
      privateKey = getPrivateKey();
      Cipher cipher = Cipher.getInstance("RSA");
      cipher.init(Cipher.DECRYPT_MODE, privateKey);
      byte[] cipherData = cipher.doFinal(encryptedBytes);
      return new String(cipherData,"UTF-16BE");               
      }
  
  public String RSAEncrypt(String plain) throws NoSuchAlgorithmException, NoSuchPaddingException,InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidKeySpecException, UnsupportedEncodingException {
  
      publicKey = getPublicKey();
      Cipher cipher = Cipher.getInstance("RSA");
      cipher.init(Cipher.ENCRYPT_MODE, publicKey);
      byte[] cipherData = cipher.doFinal(plain.getBytes());           
      return new String(cipherData,"UTF-16BE");
      }
  </code></pre>
  
  <p>Now, for example i am trying to encrypt "BAHADIR", it writes to EditText meaningless words. I used "UTF-8", "UTF-16", "UTF-16LE", "UTF16BE" and "ISO-8859-1" but everytime i get meaningless words again, not same but all of them meaningless. Where am i wrong, can you help me? Thank you. </p>