精华内容
下载资源
问答
  • js base64加密java解密

    2021-03-02 16:45:31
    js base64加密java解密js层代码java代码(创建工具类:Base64Util) js层代码 var keyStr = "ABCDEFGHIJKLMNOP" + "QRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789+/" + "="; function encode64(input) { ...

    js层代码

    var keyStr = "ABCDEFGHIJKLMNOP" + "QRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789+/" + "=";
    
    function encode64(input) {
        var output = "";
        var chr1, chr2, chr3 = "";
        var enc1, enc2, enc3, enc4 = "";
        var i = 0;
        do {
            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);
            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;
            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }
            output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2)
                + keyStr.charAt(enc3) + keyStr.charAt(enc4);
            chr1 = chr2 = chr3 = "";
            enc1 = enc2 = enc3 = enc4 = "";
        } while (i < input.length);
    
        return output;
    }
    // base64加密结束` base64加密开始
    

    java代码(创建工具类:Base64Util)

    package com.kd.system.tool;
    
    import java.io.ByteArrayOutputStream;
    
    public class Base64Util
    {
        private static byte[] base64DecodeChars = new byte[] { -1, -1, -1, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59,
                60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
                10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1,
                -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
                38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1,
                -1, -1 };
    
        /**
         * 解密
         *
         * @param str
         * @return
         */
        public static String decode(String str) {
            byte[] data = str.getBytes();
            int len = data.length;
            ByteArrayOutputStream buf = new ByteArrayOutputStream(len);
            int i = 0;
            int b1, b2, b3, b4;
    
            while (i < len) {
                do {
                    b1 = base64DecodeChars[data[i++]];
                } while (i < len && b1 == -1);
                if (b1 == -1) {
                    break;
                }
    
                do {
                    b2 = base64DecodeChars[data[i++]];
                } while (i < len && b2 == -1);
                if (b2 == -1) {
                    break;
                }
                buf.write((int) ((b1 << 2) | ((b2 & 0x30) >>> 4)));
    
                do {
                    b3 = data[i++];
                    if (b3 == 61) {
                        return new String(buf.toByteArray());
                    }
                    b3 = base64DecodeChars[b3];
                } while (i < len && b3 == -1);
                if (b3 == -1) {
                    break;
                }
                buf.write((int) (((b2 & 0x0f) << 4) | ((b3 & 0x3c) >>> 2)));
    
                do {
                    b4 = data[i++];
                    if (b4 == 61) {
                        return new String(buf.toByteArray());
                    }
                    b4 = base64DecodeChars[b4];
                } while (i < len && b4 == -1);
                if (b4 == -1) {
                    break;
                }
                buf.write((int) (((b3 & 0x03) << 6) | b4));
            }
            return new String(buf.toByteArray());
        }
    }
    
    

    解决中文乱码问题
    js层加密调用
    encode64(encodeURIComponent(psd,‘utf-8’));
    java层解密调用
    URLDecoder.decode(Base64Util.decode(password),“UTF-8”);

    展开全文
  • function Base64() {// private propertylet _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";// public method for encodingthis.encode = function(input) {var output = "";var ...

    function Base64() {

    // private property

    let _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

    // public method for encoding

    this.encode = function(input) {

    var output = "";

    var chr1, chr2, chr3, enc1, enc2, enc3, enc4;

    var i = 0;

    input = _utf8_encode(input);

    while (i < input.length) {

    chr1 = input.charCodeAt(i++);

    chr2 = input.charCodeAt(i++);

    chr3 = input.charCodeAt(i++);

    enc1 = chr1 >> 2;

    enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);

    enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);

    enc4 = chr3 & 63;

    if (isNaN(chr2)) {

    enc3 = enc4 = 64;

    } else if (isNaN(chr3)) {

    enc4 = 64;

    }

    output = output +

    _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +

    _keyStr.charAt(enc3) + _keyStr.charAt(enc4);

    }

    return output;

    }

    // public method for decoding

    this.decode = function(input) {

    var output = "";

    var chr1, chr2, chr3;

    var enc1, enc2, enc3, enc4;

    var i = 0;

    input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

    while (i < input.length) {

    enc1 = _keyStr.indexOf(input.charAt(i++));

    enc2 = _keyStr.indexOf(input.charAt(i++));

    enc3 = _keyStr.indexOf(input.charAt(i++));

    enc4 = _keyStr.indexOf(input.charAt(i++));

    chr1 = (enc1 << 2) | (enc2 >> 4);

    chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);

    chr3 = ((enc3 & 3) << 6) | enc4;

    output = output + String.fromCharCode(chr1);

    if (enc3 != 64) {

    output = output + String.fromCharCode(chr2);

    }

    if (enc4 != 64) {

    output = output + String.fromCharCode(chr3);

    }

    }

    output = _utf8_decode(output);

    return output;

    }

    // private method for UTF-8 encoding

    var _utf8_encode = function(string) {

    string = string.replace(/\r\n/g, "\n");

    var utftext = "";

    for (var n = 0; n < string.length; n++) {

    var c = string.charCodeAt(n);

    if (c < 128) {

    utftext += String.fromCharCode(c);

    } else if ((c > 127) && (c < 2048)) {

    utftext += String.fromCharCode((c >> 6) | 192);

    utftext += String.fromCharCode((c & 63) | 128);

    } else {

    utftext += String.fromCharCode((c >> 12) | 224);

    utftext += String.fromCharCode(((c >> 6) & 63) | 128);

    utftext += String.fromCharCode((c & 63) | 128);

    }

    }

    return utftext;

    }

    // private method for UTF-8 decoding

    var _utf8_decode = function(utftext) {

    var string = "";

    var i = 0;

    var c = 0,

    c1 = 0,

    c2 = 0,

    c3

    while (i < utftext.length) {

    c = utftext.charCodeAt(i);

    if (c < 128) {

    string += String.fromCharCode(c);

    i++;

    } else if ((c > 191) && (c < 224)) {

    c2 = utftext.charCodeAt(i + 1);

    string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));

    i += 2;

    } else {

    c2 = utftext.charCodeAt(i + 1);

    c3 = utftext.charCodeAt(i + 2);

    string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));

    i += 3;

    }

    }

    return string;

    }

    }

    export default Base64

    使用方法

    import Base64 from './Base64.js'

    export function encryption(str) {

    let base = new Base64()

    let result = base.encode(str)

    return result

    }

    export function decryption(str) {

    let base = new Base64()

    let result = base.decode(str)

    return result

    }

    展开全文
  • JS、Java相互加密解密 代码获取路径 ...提取码:sp21 底部也有源码 实现说明 JS加密 code = aesMinEncrypt(code);...Java解密 code = AesMin.aesDecrypt(code);// AES解密 pass = BASE64Util.decode(pas

    JS、Java相互加密解密

    代码获取路径
    百度网盘:https://pan.baidu.com/s/1wyEOoBFfRReGm5tuxwhGTQ
    提取码:sp21
    底部也有源码
    实现说明

    JS加密
    code = aesMinEncrypt(code);// AES加密
    pass = $.base64.encode(pass)// base64加密
    
    Java解密
    code = AesMin.aesDecrypt(code);// AES解密
    pass = BASE64Util.decode(pass);// base64解密
    
    Java 加密
    code = AesMin.aesEncrypt(code); // AES加密
    pass = BASE64Util.encode(pass);// base64加密
    
    JS解密
    code = aesDecrypt(code); // AES 解密
    pass = $.base64.decode(pass, "utf-8");// base64 解密
    

    BASE64解密乱码问题
    在BASE64Util.java中
    在这里插入图片描述

    说明
    建议合并使用加密
    先base64加密再AES加密

    在aes.min.js中可以自定义加密、解密字符串(注:前后端保持一致)
    在这里插入图片描述

    源码

    AesMin.java

    package com.util;
    
    import org.apache.commons.codec.binary.Base64;
    import org.apache.commons.lang.StringUtils;
    
    import javax.crypto.Cipher;
    import javax.crypto.spec.IvParameterSpec;
    import javax.crypto.spec.SecretKeySpec;
    import java.nio.charset.StandardCharsets;
    
    public class AesMin {
        
        //密钥 (需要前端和后端保持一致)十六位作为密钥
        private static final String KEY = "abcdeForTodo_Key";
    
        //密钥偏移量 (需要前端和后端保持一致)十六位作为密钥偏移量
        private static final String IV = "abcdeForTodo_Tvs";
        
        //算法
        private static final String ALGORITHMSTR = "AES/CBC/PKCS5Padding";
        
        /** 
         * base 64 decode 
         * @param base64Code 待解码的base 64 code 
         * @return 解码后的byte[] 
         * @throws Exception 
         */
        @SuppressWarnings("static-access")
    	public static byte[] base64Decode(String base64Code) throws Exception{
            /**sun.misc.BASE64Decoder是java内部类,有时候会报错,
             * 用org.apache.commons.codec.binary.Base64替代,效果一样。
             */
            //Base64 base64 = new Base64();
            //byte[] bytes = base64.decodeBase64(new String(base64Code).getBytes());
            //new BASE64Decoder().decodeBuffer(base64Code);
            return StringUtils.isEmpty(base64Code) ? null : new Base64().decodeBase64(new String(base64Code).getBytes());
        }
        
        /** 
         * AES解密 
         * @param encryptBytes 待解密的byte[] 
         * @return 解密后的String 
         * @throws Exception 
         */  
        public static String aesDecryptByBytes(byte[] encryptBytes) throws Exception {
    
            Cipher cipher = Cipher.getInstance(ALGORITHMSTR);
            
            byte[] temp = IV.getBytes("UTF-8");
            IvParameterSpec iv = new IvParameterSpec(temp);
            
            cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(KEY.getBytes(), "AES"), iv);
            byte[] decryptBytes = cipher.doFinal(encryptBytes);
            
            //System.out.println(new String(decryptBytes));
            return new String(decryptBytes);
        }
    
        /** 
         * 将base 64 code AES解密 
         * @param encryptStr 待解密的base 64 code
         * @return 解密后的string
         * @throws Exception
         */ 
        public static String aesDecrypt(String encryptStr) throws Exception {  
            return StringUtils.isEmpty(encryptStr) ? null : aesDecryptByBytes(base64Decode(encryptStr));
        }
    
        @SuppressWarnings("unused")
        public static String aesEncrypt(String str) {
            try {
                Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
                IvParameterSpec iv = new IvParameterSpec(IV.getBytes(StandardCharsets.US_ASCII));
                cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(KEY.getBytes(StandardCharsets.US_ASCII), "AES"), iv);
                byte[] encryptBytes = cipher.doFinal(str.getBytes(StandardCharsets.UTF_8));
                return new String(Base64.encodeBase64(encryptBytes),StandardCharsets.US_ASCII);
                //return java.util.Base64.getEncoder().encodeToString(encryptBytes);
            }
            catch (Exception e) {
                e.printStackTrace();
                return "";
            }
        }
    
        public static void main(String[] args) throws Exception {
            String a1=aesEncrypt("12345asdfg");
            System.out.println(a1);
            try {
                String a2 =aesDecrypt(a1);
                System.out.println(a2);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    

    BASE64Util.java

    package com.util;
    
    import sun.misc.BASE64Decoder;
    import sun.misc.BASE64Encoder;
    
    import java.io.IOException;
    
    
    /**
     * @author yyq
     * @create 2020/09/25
     */
    public class BASE64Util {
        /**
         * 采用BASE64算法对字符串进行加密
         * @param base 原字符串
         * @return 加密后的字符串
         */
        public static final String encode(String base){
            return BASE64Util.encode(base.getBytes());
        }
    
        /**
         * 采用BASE64算法对字节数组进行加密
         * @param baseBuff 原字节数组
         * @return 加密后的字符串
         */
        public static final String encode(byte[] baseBuff){
            return new BASE64Encoder().encode(baseBuff);
        }
    
        /**
         * 字符串解密,采用BASE64的算法
         * @param encoder 需要解密的字符串
         * @return 解密后的字符串
         */
        public static final String decode(String encoder){
            try {
                BASE64Decoder decoder = new BASE64Decoder();
                byte[] buf = decoder.decodeBuffer(encoder);
                return new String(buf);
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }
    
    }
    
    

    aes.min.js

    !function(t,n){"object"==typeof exports?module.exports=exports=n():"function"==typeof define&&define.amd?define([],n):t.CryptoJS=n()}(this,function(){var t=t||function(t,n){var i=Object.create||function(){function t(){}return function(n){var i;return t.prototype=n,i=new t,t.prototype=null,i}}(),e={},r=e.lib={},o=r.Base=function(){return{extend:function(t){var n=i(this);return t&&n.mixIn(t),n.hasOwnProperty("init")&&this.init!==n.init||(n.init=function(){n.$super.init.apply(this,arguments)}),n.init.prototype=n,n.$super=this,n},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var n in t)t.hasOwnProperty(n)&&(this[n]=t[n]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),s=r.WordArray=o.extend({init:function(t,i){t=this.words=t||[],i!=n?this.sigBytes=i:this.sigBytes=4*t.length},toString:function(t){return(t||c).stringify(this)},concat:function(t){var n=this.words,i=t.words,e=this.sigBytes,r=t.sigBytes;if(this.clamp(),e%4)for(var o=0;o<r;o++){var s=i[o>>>2]>>>24-o%4*8&255;n[e+o>>>2]|=s<<24-(e+o)%4*8}else for(var o=0;o<r;o+=4)n[e+o>>>2]=i[o>>>2];return this.sigBytes+=r,this},clamp:function(){var n=this.words,i=this.sigBytes;n[i>>>2]&=4294967295<<32-i%4*8,n.length=t.ceil(i/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(n){for(var i,e=[],r=function(n){var n=n,i=987654321,e=4294967295;return function(){i=36969*(65535&i)+(i>>16)&e,n=18e3*(65535&n)+(n>>16)&e;var r=(i<<16)+n&e;return r/=4294967296,r+=.5,r*(t.random()>.5?1:-1)}},o=0;o<n;o+=4){var a=r(4294967296*(i||t.random()));i=987654071*a(),e.push(4294967296*a()|0)}return new s.init(e,n)}}),a=e.enc={},c=a.Hex={stringify:function(t){for(var n=t.words,i=t.sigBytes,e=[],r=0;r<i;r++){var o=n[r>>>2]>>>24-r%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},parse:function(t){for(var n=t.length,i=[],e=0;e<n;e+=2)i[e>>>3]|=parseInt(t.substr(e,2),16)<<24-e%8*4;return new s.init(i,n/2)}},u=a.Latin1={stringify:function(t){for(var n=t.words,i=t.sigBytes,e=[],r=0;r<i;r++){var o=n[r>>>2]>>>24-r%4*8&255;e.push(String.fromCharCode(o))}return e.join("")},parse:function(t){for(var n=t.length,i=[],e=0;e<n;e++)i[e>>>2]|=(255&t.charCodeAt(e))<<24-e%4*8;return new s.init(i,n)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},h=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(n){var i=this._data,e=i.words,r=i.sigBytes,o=this.blockSize,a=4*o,c=r/a;c=n?t.ceil(c):t.max((0|c)-this._minBufferSize,0);var u=c*o,f=t.min(4*u,r);if(u){for(var h=0;h<u;h+=o)this._doProcessBlock(e,h);var p=e.splice(0,u);i.sigBytes-=f}return new s.init(p,f)},clone:function(){var t=o.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),p=(r.Hasher=h.extend({cfg:o.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){t&&this._append(t);var n=this._doFinalize();return n},blockSize:16,_createHelper:function(t){return function(n,i){return new t.init(i).finalize(n)}},_createHmacHelper:function(t){return function(n,i){return new p.HMAC.init(t,i).finalize(n)}}}),e.algo={});return e}(Math);return t});
    //# sourceMappingURL=core.min.js.map
    !function(e,t,i){"object"==typeof exports?module.exports=exports=t(require("./core.min"),require("./sha1.min"),require("./hmac.min")):"function"==typeof define&&define.amd?define(["./core.min","./sha1.min","./hmac.min"],t):t(e.CryptoJS)}(this,function(e){return function(){var t=e,i=t.lib,r=i.Base,n=i.WordArray,o=t.algo,a=o.MD5,c=o.EvpKDF=r.extend({cfg:r.extend({keySize:4,hasher:a,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i=this.cfg,r=i.hasher.create(),o=n.create(),a=o.words,c=i.keySize,f=i.iterations;a.length<c;){s&&r.update(s);var s=r.update(e).finalize(t);r.reset();for(var u=1;u<f;u++)s=r.finalize(s),r.reset();o.concat(s)}return o.sigBytes=4*c,o}});t.EvpKDF=function(e,t,i){return c.create(i).compute(e,t)}}(),e.EvpKDF});
    //# sourceMappingURL=evpkdf.min.js.map
    !function(r,e){"object"==typeof exports?module.exports=exports=e(require("./core.min")):"function"==typeof define&&define.amd?define(["./core.min"],e):e(r.CryptoJS)}(this,function(r){return function(){function e(r,e,t){for(var n=[],i=0,o=0;o<e;o++)if(o%4){var f=t[r.charCodeAt(o-1)]<<o%4*2,c=t[r.charCodeAt(o)]>>>6-o%4*2;n[i>>>2]|=(f|c)<<24-i%4*8,i++}return a.create(n,i)}var t=r,n=t.lib,a=n.WordArray,i=t.enc;i.Base64={stringify:function(r){var e=r.words,t=r.sigBytes,n=this._map;r.clamp();for(var a=[],i=0;i<t;i+=3)for(var o=e[i>>>2]>>>24-i%4*8&255,f=e[i+1>>>2]>>>24-(i+1)%4*8&255,c=e[i+2>>>2]>>>24-(i+2)%4*8&255,s=o<<16|f<<8|c,h=0;h<4&&i+.75*h<t;h++)a.push(n.charAt(s>>>6*(3-h)&63));var p=n.charAt(64);if(p)for(;a.length%4;)a.push(p);return a.join("")},parse:function(r){var t=r.length,n=this._map,a=this._reverseMap;if(!a){a=this._reverseMap=[];for(var i=0;i<n.length;i++)a[n.charCodeAt(i)]=i}var o=n.charAt(64);if(o){var f=r.indexOf(o);f!==-1&&(t=f)}return e(r,t,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),r.enc.Base64});
    //# sourceMappingURL=enc-base64.min.js.map
    !function(e,t,r){"object"==typeof exports?module.exports=exports=t(require("./core.min"),require("./evpkdf.min")):"function"==typeof define&&define.amd?define(["./core.min","./evpkdf.min"],t):t(e.CryptoJS)}(this,function(e){e.lib.Cipher||function(t){var r=e,i=r.lib,n=i.Base,c=i.WordArray,o=i.BufferedBlockAlgorithm,s=r.enc,a=(s.Utf8,s.Base64),f=r.algo,p=f.EvpKDF,d=i.Cipher=o.extend({cfg:n.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){e&&this._append(e);var t=this._doFinalize();return t},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?B:x}return function(t){return{encrypt:function(r,i,n){return e(i).encrypt(t,r,i,n)},decrypt:function(r,i,n){return e(i).decrypt(t,r,i,n)}}}}()}),h=(i.StreamCipher=d.extend({_doFinalize:function(){var e=this._process(!0);return e},blockSize:1}),r.mode={}),u=i.BlockCipherMode=n.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),l=h.CBC=function(){function e(e,r,i){var n=this._iv;if(n){var c=n;this._iv=t}else var c=this._prevBlock;for(var o=0;o<i;o++)e[r+o]^=c[o]}var r=u.extend();return r.Encryptor=r.extend({processBlock:function(t,r){var i=this._cipher,n=i.blockSize;e.call(this,t,r,n),i.encryptBlock(t,r),this._prevBlock=t.slice(r,r+n)}}),r.Decryptor=r.extend({processBlock:function(t,r){var i=this._cipher,n=i.blockSize,c=t.slice(r,r+n);i.decryptBlock(t,r),e.call(this,t,r,n),this._prevBlock=c}}),r}(),_=r.pad={},v=_.Pkcs7={pad:function(e,t){for(var r=4*t,i=r-e.sigBytes%r,n=i<<24|i<<16|i<<8|i,o=[],s=0;s<i;s+=4)o.push(n);var a=c.create(o,i);e.concat(a)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},y=(i.BlockCipher=d.extend({cfg:d.cfg.extend({mode:l,padding:v}),reset:function(){d.reset.call(this);var e=this.cfg,t=e.iv,r=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=r.createEncryptor;else{var i=r.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==i?this._mode.init(this,t&&t.words):(this._mode=i.call(r,this,t&&t.words),this._mode.__creator=i)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else{var t=this._process(!0);e.unpad(t)}return t},blockSize:4}),i.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}})),m=r.format={},k=m.OpenSSL={stringify:function(e){var t=e.ciphertext,r=e.salt;if(r)var i=c.create([1398893684,1701076831]).concat(r).concat(t);else var i=t;return i.toString(a)},parse:function(e){var t=a.parse(e),r=t.words;if(1398893684==r[0]&&1701076831==r[1]){var i=c.create(r.slice(2,4));r.splice(0,4),t.sigBytes-=16}return y.create({ciphertext:t,salt:i})}},x=i.SerializableCipher=n.extend({cfg:n.extend({format:k}),encrypt:function(e,t,r,i){i=this.cfg.extend(i);var n=e.createEncryptor(r,i),c=n.finalize(t),o=n.cfg;return y.create({ciphertext:c,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:i.format})},decrypt:function(e,t,r,i){i=this.cfg.extend(i),t=this._parse(t,i.format);var n=e.createDecryptor(r,i).finalize(t.ciphertext);return n},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),g=r.kdf={},S=g.OpenSSL={execute:function(e,t,r,i){i||(i=c.random(8));var n=p.create({keySize:t+r}).compute(e,i),o=c.create(n.words.slice(t),4*r);return n.sigBytes=4*t,y.create({key:n,iv:o,salt:i})}},B=i.PasswordBasedCipher=x.extend({cfg:x.cfg.extend({kdf:S}),encrypt:function(e,t,r,i){i=this.cfg.extend(i);var n=i.kdf.execute(r,e.keySize,e.ivSize);i.iv=n.iv;var c=x.encrypt.call(this,e,t,n.key,i);return c.mixIn(n),c},decrypt:function(e,t,r,i){i=this.cfg.extend(i),t=this._parse(t,i.format);var n=i.kdf.execute(r,e.keySize,e.ivSize,t.salt);i.iv=n.iv;var c=x.decrypt.call(this,e,t,n.key,i);return c}})}()});
    //# sourceMappingURL=cipher-core.min.js.map
    !function(e,i){"object"==typeof exports?module.exports=exports=i(require("./core.min")):"function"==typeof define&&define.amd?define(["./core.min"],i):i(e.CryptoJS)}(this,function(e){!function(){var i=e,t=i.lib,n=t.Base,s=i.enc,r=s.Utf8,o=i.algo;o.HMAC=n.extend({init:function(e,i){e=this._hasher=new e.init,"string"==typeof i&&(i=r.parse(i));var t=e.blockSize,n=4*t;i.sigBytes>n&&(i=e.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),o=this._iKey=i.clone(),a=s.words,f=o.words,c=0;c<t;c++)a[c]^=1549556828,f[c]^=909522486;s.sigBytes=o.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var i=this._hasher,t=i.finalize(e);i.reset();var n=i.finalize(this._oKey.clone().concat(t));return n}})}()});
    //# sourceMappingURL=hmac.min.js.map
    !function(e,o,r){"object"==typeof exports?module.exports=exports=o(require("./core.min"),require("./cipher-core.min")):"function"==typeof define&&define.amd?define(["./core.min","./cipher-core.min"],o):o(e.CryptoJS)}(this,function(e){return e.mode.ECB=function(){var o=e.lib.BlockCipherMode.extend();return o.Encryptor=o.extend({processBlock:function(e,o){this._cipher.encryptBlock(e,o)}}),o.Decryptor=o.extend({processBlock:function(e,o){this._cipher.decryptBlock(e,o)}}),o}(),e.mode.ECB});
    //# sourceMappingURL=mode-ecb.min.js.map
    !function(e,r,i){"object"==typeof exports?module.exports=exports=r(require("./core.min"),require("./cipher-core.min")):"function"==typeof define&&define.amd?define(["./core.min","./cipher-core.min"],r):r(e.CryptoJS)}(this,function(e){return e.pad.Pkcs7});
    //# sourceMappingURL=pad-pkcs7.min.js.map
    !function(e,r,i){"object"==typeof exports?module.exports=exports=r(require("./core.min"),require("./enc-base64.min"),require("./md5.min"),require("./evpkdf.min"),require("./cipher-core.min")):"function"==typeof define&&define.amd?define(["./core.min","./enc-base64.min","./md5.min","./evpkdf.min","./cipher-core.min"],r):r(e.CryptoJS)}(this,function(e){return function(){var r=e,i=r.lib,n=i.BlockCipher,o=r.algo,t=[],c=[],s=[],f=[],a=[],d=[],u=[],v=[],h=[],y=[];!function(){for(var e=[],r=0;r<256;r++)r<128?e[r]=r<<1:e[r]=r<<1^283;for(var i=0,n=0,r=0;r<256;r++){var o=n^n<<1^n<<2^n<<3^n<<4;o=o>>>8^255&o^99,t[i]=o,c[o]=i;var p=e[i],l=e[p],_=e[l],k=257*e[o]^16843008*o;s[i]=k<<24|k>>>8,f[i]=k<<16|k>>>16,a[i]=k<<8|k>>>24,d[i]=k;var k=16843009*_^65537*l^257*p^16843008*i;u[o]=k<<24|k>>>8,v[o]=k<<16|k>>>16,h[o]=k<<8|k>>>24,y[o]=k,i?(i=p^e[e[e[_^p]]],n^=e[e[n]]):i=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],l=o.AES=n.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,r=e.words,i=e.sigBytes/4,n=this._nRounds=i+6,o=4*(n+1),c=this._keySchedule=[],s=0;s<o;s++)if(s<i)c[s]=r[s];else{var f=c[s-1];s%i?i>6&&s%i==4&&(f=t[f>>>24]<<24|t[f>>>16&255]<<16|t[f>>>8&255]<<8|t[255&f]):(f=f<<8|f>>>24,f=t[f>>>24]<<24|t[f>>>16&255]<<16|t[f>>>8&255]<<8|t[255&f],f^=p[s/i|0]<<24),c[s]=c[s-i]^f}for(var a=this._invKeySchedule=[],d=0;d<o;d++){var s=o-d;if(d%4)var f=c[s];else var f=c[s-4];d<4||s<=4?a[d]=f:a[d]=u[t[f>>>24]]^v[t[f>>>16&255]]^h[t[f>>>8&255]]^y[t[255&f]]}}},encryptBlock:function(e,r){this._doCryptBlock(e,r,this._keySchedule,s,f,a,d,t)},decryptBlock:function(e,r){var i=e[r+1];e[r+1]=e[r+3],e[r+3]=i,this._doCryptBlock(e,r,this._invKeySchedule,u,v,h,y,c);var i=e[r+1];e[r+1]=e[r+3],e[r+3]=i},_doCryptBlock:function(e,r,i,n,o,t,c,s){for(var f=this._nRounds,a=e[r]^i[0],d=e[r+1]^i[1],u=e[r+2]^i[2],v=e[r+3]^i[3],h=4,y=1;y<f;y++){var p=n[a>>>24]^o[d>>>16&255]^t[u>>>8&255]^c[255&v]^i[h++],l=n[d>>>24]^o[u>>>16&255]^t[v>>>8&255]^c[255&a]^i[h++],_=n[u>>>24]^o[v>>>16&255]^t[a>>>8&255]^c[255&d]^i[h++],k=n[v>>>24]^o[a>>>16&255]^t[d>>>8&255]^c[255&u]^i[h++];a=p,d=l,u=_,v=k}var p=(s[a>>>24]<<24|s[d>>>16&255]<<16|s[u>>>8&255]<<8|s[255&v])^i[h++],l=(s[d>>>24]<<24|s[u>>>16&255]<<16|s[v>>>8&255]<<8|s[255&a])^i[h++],_=(s[u>>>24]<<24|s[v>>>16&255]<<16|s[a>>>8&255]<<8|s[255&d])^i[h++],k=(s[v>>>24]<<24|s[a>>>16&255]<<16|s[d>>>8&255]<<8|s[255&u])^i[h++];e[r]=p,e[r+1]=l,e[r+2]=_,e[r+3]=k},keySize:8});r.AES=n._createHelper(l)}(),e.AES});
    //# sourceMappingURL=aes.min.js.map
    !function(e,n){"object"==typeof exports?module.exports=exports=n(require("./core.min")):"function"==typeof define&&define.amd?define(["./core.min"],n):n(e.CryptoJS)}(this,function(e){return e.enc.Utf8});
    //# sourceMappingURL=enc-utf8.min.js.map
    
    /** yyq
     *  2020-09-25
     * @param word
     * @returns {*}
     */
    function aesMinEncrypt(word){
        var _word = CryptoJS.enc.Utf8.parse(word),
            _key = CryptoJS.enc.Utf8.parse("abcdeForTodo_Key"),
            _iv = CryptoJS.enc.Utf8.parse("abcdeForTodo_Tvs");
        var encrypted = CryptoJS.AES.encrypt(_word, _key, {
                    iv: _iv,
                    mode: CryptoJS.mode.CBC,
                    padding: CryptoJS.pad.Pkcs7
            });
        return encrypted.toString();
    }
    /** yyq
     *  2020-09-25
     * @param word
     * @returns {*}
     */
    function aesDecrypt(word) {
        var _key = CryptoJS.enc.Utf8.parse("abcdeForTodo_Key"),
            _iv = CryptoJS.enc.Utf8.parse("abcdeForTodo_Tvs");
        var decrypted = CryptoJS.AES.decrypt(word, _key, {
                    iv: _iv,
                    mode: CryptoJS.mode.CBC,
                    padding: CryptoJS.pad.Pkcs7
            });
        return decrypted.toString(CryptoJS.enc.Utf8);
    }
    

    jquery.base64.js

    "use strict";jQuery.base64=(function($){var _PADCHAR="=",_ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_VERSION="1.0";function _getbyte64(s,i){var idx=_ALPHA.indexOf(s.charAt(i));if(idx===-1){throw"Cannot decode base64"}return idx}function _decode(s){var pads=0,i,b10,imax=s.length,x=[];s=String(s);if(imax===0){return s}if(imax%4!==0){throw"Cannot decode base64"}if(s.charAt(imax-1)===_PADCHAR){pads=1;if(s.charAt(imax-2)===_PADCHAR){pads=2}imax-=4}for(i=0;i<imax;i+=4){b10=(_getbyte64(s,i)<<18)|(_getbyte64(s,i+1)<<12)|(_getbyte64(s,i+2)<<6)|_getbyte64(s,i+3);x.push(String.fromCharCode(b10>>16,(b10>>8)&255,b10&255))}switch(pads){case 1:b10=(_getbyte64(s,i)<<18)|(_getbyte64(s,i+1)<<12)|(_getbyte64(s,i+2)<<6);x.push(String.fromCharCode(b10>>16,(b10>>8)&255));break;case 2:b10=(_getbyte64(s,i)<<18)|(_getbyte64(s,i+1)<<12);x.push(String.fromCharCode(b10>>16));break}return x.join("")}function _getbyte(s,i){var x=s.charCodeAt(i);if(x>255){throw"INVALID_CHARACTER_ERR: DOM Exception 5"}return x}function _encode(s){if(arguments.length!==1){throw"SyntaxError: exactly one argument required"}s=String(s);var i,b10,x=[],imax=s.length-s.length%3;if(s.length===0){return s}for(i=0;i<imax;i+=3){b10=(_getbyte(s,i)<<16)|(_getbyte(s,i+1)<<8)|_getbyte(s,i+2);x.push(_ALPHA.charAt(b10>>18));x.push(_ALPHA.charAt((b10>>12)&63));x.push(_ALPHA.charAt((b10>>6)&63));x.push(_ALPHA.charAt(b10&63))}switch(s.length-imax){case 1:b10=_getbyte(s,i)<<16;x.push(_ALPHA.charAt(b10>>18)+_ALPHA.charAt((b10>>12)&63)+_PADCHAR+_PADCHAR);break;case 2:b10=(_getbyte(s,i)<<16)|(_getbyte(s,i+1)<<8);x.push(_ALPHA.charAt(b10>>18)+_ALPHA.charAt((b10>>12)&63)+_ALPHA.charAt((b10>>6)&63)+_PADCHAR);break}return x.join("")}return{decode:_decode,encode:_encode,VERSION:_VERSION}}(jQuery));
    
    展开全文
  • Base64加密解密java/js

    2013-02-01 16:17:20
    参照网上Base64 js加密解密写的java实现,网上没看到出现过,可能大神都不屑写这种小东东,只好自己写了。弄了好几天,总算弄好了。 因为是参照 js Base64写的java实现,所以代码可实现前台js,后台java加密,...
  • js base64加密解密

    2018-09-05 15:12:37
    base64加密解密源码,纯js编写,内容copy于互联网,用作保留使用。
  • 下面小编就为大家分享一篇java8版本base64加密解密的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
  • base64加密解密

    2021-01-29 09:56:43
    1.base64.js /*! * jquery.base64.js 0.1 - https://github.com/yckart/jquery.base64.js * Makes Base64 en & -decoding simpler as it is. * * Based upon: https://gist.github.com/Yaffle/1284012 * *...

    前端:
    1.base64.js

    /*!
     * jquery.base64.js 0.1 - https://github.com/yckart/jquery.base64.js
     * Makes Base64 en & -decoding simpler as it is.
     *
     * Based upon: https://gist.github.com/Yaffle/1284012
     *
     * Copyright (c) 2012 Yannick Albert (http://yckart.com)
     * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php).
     * 2013/02/10
     **/
    ;(function($) {
    
        var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
            a256 = '',
            r64 = [256],
            r256 = [256],
            i = 0;
    
        var UTF8 = {
    
            /**
             * Encode multi-byte Unicode string into utf-8 multiple single-byte characters
             * (BMP / basic multilingual plane only)
             *
             * Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars
             *
             * @param {String} strUni Unicode string to be encoded as UTF-8
             * @returns {String} encoded string
             */
            encode: function(strUni) {
                // use regular expressions & String.replace callback function for better efficiency
                // than procedural approaches
                var strUtf = strUni.replace(/[\u0080-\u07ff]/g, // U+0080 - U+07FF => 2 bytes 110yyyyy, 10zzzzzz
                    function(c) {
                        var cc = c.charCodeAt(0);
                        return String.fromCharCode(0xc0 | cc >> 6, 0x80 | cc & 0x3f);
                    })
                    .replace(/[\u0800-\uffff]/g, // U+0800 - U+FFFF => 3 bytes 1110xxxx, 10yyyyyy, 10zzzzzz
                        function(c) {
                            var cc = c.charCodeAt(0);
                            return String.fromCharCode(0xe0 | cc >> 12, 0x80 | cc >> 6 & 0x3F, 0x80 | cc & 0x3f);
                        });
                return strUtf;
            },
    
            /**
             * Decode utf-8 encoded string back into multi-byte Unicode characters
             *
             * @param {String} strUtf UTF-8 string to be decoded back to Unicode
             * @returns {String} decoded string
             */
            decode: function(strUtf) {
                // note: decode 3-byte chars first as decoded 2-byte strings could appear to be 3-byte char!
                var strUni = strUtf.replace(/[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g, // 3-byte chars
                    function(c) { // (note parentheses for precence)
                        var cc = ((c.charCodeAt(0) & 0x0f) << 12) | ((c.charCodeAt(1) & 0x3f) << 6) | (c.charCodeAt(2) & 0x3f);
                        return String.fromCharCode(cc);
                    })
                    .replace(/[\u00c0-\u00df][\u0080-\u00bf]/g, // 2-byte chars
                        function(c) { // (note parentheses for precence)
                            var cc = (c.charCodeAt(0) & 0x1f) << 6 | c.charCodeAt(1) & 0x3f;
                            return String.fromCharCode(cc);
                        });
                return strUni;
            }
        };
    
        while(i < 256) {
            var c = String.fromCharCode(i);
            a256 += c;
            r256[i] = i;
            r64[i] = b64.indexOf(c);
            ++i;
        }
    
        function code(s, discard, alpha, beta, w1, w2) {
            s = String(s);
            var buffer = 0,
                i = 0,
                length = s.length,
                result = '',
                bitsInBuffer = 0;
    
            while(i < length) {
                var c = s.charCodeAt(i);
                c = c < 256 ? alpha[c] : -1;
    
                buffer = (buffer << w1) + c;
                bitsInBuffer += w1;
    
                while(bitsInBuffer >= w2) {
                    bitsInBuffer -= w2;
                    var tmp = buffer >> bitsInBuffer;
                    result += beta.charAt(tmp);
                    buffer ^= tmp << bitsInBuffer;
                }
                ++i;
            }
            if(!discard && bitsInBuffer > 0) result += beta.charAt(buffer << (w2 - bitsInBuffer));
            return result;
        }
    
        var Plugin = $.base64 = function(dir, input, encode) {
            return input ? Plugin[dir](input, encode) : dir ? null : this;
        };
    
        Plugin.btoa = Plugin.encode = function(plain, utf8encode) {
            plain = Plugin.raw === false || Plugin.utf8encode || utf8encode ? UTF8.encode(plain) : plain;
            plain = code(plain, false, r256, b64, 8, 6);
            return plain + '===='.slice((plain.length % 4) || 4);
        };
    
        Plugin.atob = Plugin.decode = function(coded, utf8decode) {
            coded = String(coded).split('=');
            var i = coded.length;
            do {--i;
                coded[i] = code(coded[i], true, r64, a256, 6, 8);
            } while (i > 0);
            coded = coded.join('');
            return Plugin.raw === false || Plugin.utf8decode || utf8decode ? UTF8.decode(coded) : coded;
        };
    }(jQuery));
    
    

    html页面使用:
    1.引用js:

    <script type="text/javascript" src="../js/base64.js"></script>
    

    原文:

     var time="timestamp="+new Date().getTime()
    

    2.加密

     var str= window.btoa(unescape(encodeURIComponent(time)))
            console.log("加密:"+str)
    

    3.解密

     var dstr = decodeURIComponent(escape(window.atob(str)))
            console.log("解密:"+dstr)
            alert(dstr)
    

    Java后台:
    1.base64util工具类:

    package com.soft.util;
    
    import java.io.UnsupportedEncodingException;
    
    import sun.misc.BASE64Decoder;
    import sun.misc.BASE64Encoder;
    
    public class Base64Util {
        public static void main(String[] args) {
            String str = "wew反对发射点开发";
            String base64 = getBase64(str);
            System.out.println(base64);
            String pwd = "S0hOcGh0YXpXSlhmRDVOVTE2MTE4MjMwMDQ5MzFuYW1lYWRtaW5wd2Qx";
            String res = getFromBase64(pwd);
            System.out.println("解密:" + res);
        }
    
        //加密  
        public static String getBase64(String str) {
            byte[] b = null;
            String s = null;
            try {
                b = str.getBytes("utf-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            if (b != null) {
                s = new BASE64Encoder().encode(b);
            }
            return s;
        }
    
        // 解密    
        public static String getFromBase64(String s) {
            byte[] b = null;
            String result = null;
            if (s != null) {
                BASE64Decoder decoder = new BASE64Decoder();
                try {
                    b = decoder.decodeBuffer(s);
                    result = new String(b, "utf-8");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return result;
        }
    }
    
    

    2.获取前台传过来的加密参数进行解密:

            String loginUserToken = request.getHeader("singe");
            byte[] textByte = loginUserToken.getBytes("UTF-8");
            String word = new String(textByte, "utf-8");
             //对加密数据进行解密
            String result = Base64Util.getFromBase64(word);
    
    展开全文
  • Base64加密解密

    2018-09-19 14:38:45
    Base64加密解密方法,包括一个java文件和一个js文件。
  • 一、js加密java解密 1、js加密 1、中文字符串加密 2、英文等字符串加密 3、中文字符串混淆、迭代加密 4、英文等字符串混淆、迭代加密 5、JSON数据混淆、迭代加密 2、Java解密 二、java加密js解密 1、...
  • String decodedString = new String(base64.decode(encodedString.getBytes()));
  • 主要介绍了jQuery实现base64前台加密解密功能,结合实例形式分析了jquery.base64.js实现前台base64加密解密功能的实现方法,并给出了java实现后台base64加密解密的操作示例对比验证加密效果,需要的朋友可以参考下
  • 对文件进行zip压缩 和base64加密解密的几个工具类
  • JavaScript - Base64加密解密 /** * * [ Base64 encode / decode ] * [ 后端使用 java.util.Base64 可实现解密 ] * */ function Base64() { // private property let _keyStr = '...
  • base64加密解密-java版和js

    千次阅读 2016-09-05 18:09:06
    一、Base64简介: Base64编码要求把3个8位字节(3*8=24)转化为4个6位的字节(4*6=24),之后在6位的前面补两个0,形成8位一个字节的形式。 如果剩下的字符不足3个字节,则用0填充,输出字符使用‘=’,因此编码后...
  • 问题:对JSON字符串,用JSBase64加密和用JavaBase64加密,得到的字符串不一致(二者加密后的字符串均能解码为正确的JSON字符串);怎样才能用Java实现和JSbase64加密一样效果的字符串?请过路的各位大佬帮忙...
  • 这次给大家带来base64实现加密解密功能,base64实现加密解密功能的注意事项...如果只是想做加密解密,类似于Java的DES,网上jQuery有个jquery.base64.js。(关于js的md5加密可以用jquery.md5.js,有兴趣可以找来测试...
  • j2ee精英团队十年编程精华大放送,本代码包功能:java对字串进行Base64加密解密
  • base64加密解密-js-utf-8

    2012-07-11 11:46:39
    base64中文加密 注意中文编码为UTF-8
  • Base64加密/解密(前台和后台)

    千次阅读 2018-09-07 17:56:06
    js前台实现Base64加密/解密(encoder/decoder) 在js文件中编写以下代码 function btn_test(){ window.wxc.xcConfirm('成功!', window.wxc.xcConfirm.typeEnum.success); var pwd = $(&quot;#pwd_id&...
  • package cn.ljs.util; ...import java.util.Base64; import java.util.Base64.Decoder; import java.util.Base64.Encoder; import java.util.HashMap; import java.util.List; import java.uti...
  • 引入base64.js var jsonStr = '{"A":"","B":"https://www.syjalor.com","c":""}'; //var data = JSON.parse(jsonStr);//转换为json对象 var encoded = Base64[ 'encode' + ($('encodeURI').checked ? 'URI' : '')...
  • 前段时间,工作需要,需要用jsjava配套的base64算法,奈何没找到,然后网上抄一套。用起来还是很有效的。闲言少絮,直接上干货。jsbase 64 算法 base64.jsvarkeyStr=...
  • 项目中遇到将中文从前台传到后台过程中,出现乱码,一番尝试之后,均是乱码,然后尝试在js代码中先进行base64加密,然后在java中再进行解密,完美的解决了乱码问题,步骤如下 一,html页面引入jquery.base64.js 下载地址如下...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 7,263
精华内容 2,905
关键字:

base64加密java解密js

java 订阅