public static String encrypt ( String cleartext ) { if ( cleartext != null ) { byte [ ] result = doFinal ( Base64 . decode ( getBase64Key ( ) , Base64 . DEFAULT ) , Cipher . ENCRYPT_MODE , cleartext . getBytes ( ) ) ; return Base64 . encodeToString ( result , Base64 . DEFAULT ) ; } return null ; }
Returns the data encrypted . Avoid calling this method on the UI thread if possible since it may access to shared preferences .