Java工具类-BASE64加解密

    技术2022-07-11  150

    1 引入apache commons-codec依赖

    <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.10</version> </dependency>

    2 使用Base64.encodeBase64加密

    public static String base64Encode(String str){ byte[] b = Base64.encodeBase64(str.getBytes(),true); return new String(b); }

    3 使用Base64.decodeBase64解密

    public static String base64Decode(String str){ byte[] b = Base64.decodeBase64(str.getBytes()); return new String(b); }

     

    Processed: 0.009, SQL: 9