Android - decodeBase64 crashes App

后端 未结 3 1188
后悔当初
后悔当初 2021-01-22 22:51

I have to encrypt a String but the app doesn\'t reach the encrypt method, it crashes on load.
I\'m using Apache Commons Codec library.

private EditText txt         


        
3条回答
  •  自闭症患者
    2021-01-22 23:25

    Simply create an object of Base64 and use it to encode or decode in Android, when using org.apache.commons.codec.binary.Base64 library

    To Encode

    Base64 ed=new Base64();

    String encoded=new String(ed.encode("Hello".getBytes()));

    Replace "Hello" with the text to be encoded in String Format.

    To Decode

    Base64 ed=new Base64();

    String decoded=new String(ed.decode(encoded.getBytes()));

    Here encoded is the String variable to be decoded

提交回复
热议问题