Util

Util Base64加密解密

1.Base64工具類

object Base64Util {
    fun decode(str: String) = String(Base64.decode(str, Base64.DEFAULT))
    fun encode(str: String) = String(Base64.encode(str.toByteArray(), Base64.DEFAULT))
}

2.效果展示

val encode = Base64Util.encode("你好 我是Base64")
Log.e("Base64 encode:", encode)
val decode = Base64Util.decode("5L2g5aW9IOaIkeaYr0Jhc2U2NA==")
Log.e("Base64 decode:", decode)

發表迴響