Base64编码是从二进制到字符的过程,可用于在HTTP环境下传递较长的标识信息。

Base64是个字符串

pom.xml配置

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

 加密解密代码

 /**
     * 解密
     * 
     * @param pwd
     * @return
     * @see [类、类#方法、类#成员]
     */
    public static String decodeStr(String pwd)
    {
        Base64 base64 = new Base64();
        byte[] debytes = base64.decodeBase64(new String(pwd).getBytes());
        return new String(debytes);
    }
 
    /**
     * 加密
     * 
     * @param pwd
     * @return
     * @see [类、类#方法、类#成员]
     */
    public static String encodeStr(String pwd)
    {
        Base64 base64 = new Base64();
        byte[] enbytes = base64.encodeBase64Chunked(pwd.getBytes());
        return new String(enbytes);
    }

 大家觉得不错的话可以支持一下

java对Base64图片的加密解密

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2021-10-01
  • 2021-07-03
  • 2021-08-14
相关资源
相似解决方案