zoukankan      html  css  js  c++  java
  • java对Base64图片的加密解密

    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);
        }

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

  • 相关阅读:
    Acdream 1174 Sum 暴力
    Acdream 1114 Number theory 莫比乌斯反演
    Acdream 1007 快速幂,模乘法
    UVa 10023
    UVa 11027
    UVa 11029
    UVa 10820
    UVa 10791
    UVa 11121
    UVa 106
  • 原文地址:https://www.cnblogs.com/xiangxiang521/p/9454236.html
Copyright © 2011-2022 走看看