Code example for BadPaddingException

Methods: getMessage

0
      try{ 
        byte[] utf8 = toEncrypt.getBytes("UTF8");
        byte[] enc = encCipher.doFinal(utf8);
        return enc; 
      } catch(BadPaddingException e){
        Log.e(LOG_TAG, e.getMessage());
      } catch(UnsupportedEncodingException e){
        Log.e(LOG_TAG, e.getMessage());
      } catch(IllegalBlockSizeException e){
        Log.e(LOG_TAG, e.getMessage());
      } 
      return null; 
    } 
     
    private String decryptString(byte[] toDecrypt, Cipher decCipher){
      try{ 
        byte[] decrypt = decCipher.doFinal(toDecrypt);
        return new String(decrypt, "UTF8");
      } catch(BadPaddingException e){
        Log.e(LOG_TAG, e.getMessage());
Contextual code suggestions in your IDE  Get Codota for Java