Fast and simple String encrypt/decrypt in JAVA

后端 未结 4 694
猫巷女王i
猫巷女王i 2020-12-02 04:28

I need fast and simple way to encrypt/decrypt a \"lot\" of String data. I tried jasypt but it crashes on my Androi

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 05:11

    If you are using Android then you can use android.util.Base64 class.

    Encode:

    passwd = Base64.encodeToString( passwd.getBytes(), Base64.DEFAULT );
    

    Decode:

    passwd = new String( Base64.decode( passwd, Base64.DEFAULT ) );
    

    A simple and fast single line solution.

提交回复
热议问题