ソースを参照

Merge branch '王立生' of sckj/mz-cloud into master

sckj 2 年 前
コミット
a96e2ee37c

+ 5 - 0
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java

@@ -25,6 +25,11 @@ public class BaseEntity implements Serializable
     @TableField(exist = false)
     @JsonIgnore
     private String searchValue;
+    /** 搜索值 */
+    @ApiModelProperty(value = "附加SQL")
+    @TableField(exist = false)
+    @JsonIgnore
+    private String fjsql;
 
     /** 创建者 */
     @ApiModelProperty(value = "创建者")

+ 1 - 3
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/Encryption.java

@@ -60,9 +60,7 @@ public class Encryption {
     };
 
     public static String bytesToHex(byte[] bytes) {
-        String hex = new BigInteger(1, bytes).toString(16);
-        System.out.print(hex);
-        return hex;
+        return  String.format("%0"+(bytes.length << 1)+"x",new BigInteger(1, bytes));
     }
     public static String encrypt(String key, String iv,String data)  {
         try {

+ 36 - 0
ruoyi-ui/src/views/system/demo/index.vue

@@ -79,6 +79,7 @@
 import {mapGetters} from "vuex";
 import {gettreedata, objtableList,getstatisticaldata} from "@/api/system/dict/type";
 import * as echarts from "echarts";
+import CryptoJS from 'crypto-js'
 require("echarts/theme/macarons"); //引入主题
 export default {
   name: 'Demo',
@@ -118,6 +119,35 @@ export default {
     };
   },
   methods: {
+    encrypt(data){
+      let key="1234567887654321";
+      let iv=key;
+      const dataHex = CryptoJS.enc.Utf8.parse( data ) // 需要加密的数据
+      const keyHex = CryptoJS.enc.Utf8.parse( key ) // 秘钥
+      const ivHex = CryptoJS.enc.Utf8.parse( iv ) // 偏移量
+      const encrypted = CryptoJS.AES.encrypt( dataHex , keyHex , {
+        iv: ivHex,
+        mode: CryptoJS.mode.CBC,
+        padding: CryptoJS.pad.Pkcs7
+      });
+      let encryptedVal = encrypted.ciphertext.toString();
+      return encryptedVal;
+    },
+    decrypt(data){
+      let key="1234567887654321";
+      let iv=key;
+      let encryptedHexStr = CryptoJS.enc.Hex.parse( data  );
+      let srcs = CryptoJS.enc.Base64.stringify( encryptedHexStr );
+      const keyHex = CryptoJS.enc.Utf8.parse( key ) // 秘钥
+      const ivHex = CryptoJS.enc.Utf8.parse( iv ) // 偏移量
+      let decrypt = CryptoJS.AES.decrypt( srcs , keyHex , {
+        iv: ivHex,
+        mode: CryptoJS.mode.CBC,
+        padding: CryptoJS.pad.Pkcs7
+      });
+      let decryptedStr = decrypt.toString( CryptoJS.enc.Utf8 );
+      return decryptedStr.toString();
+    },
     indexMethod(index)
     {
       let curpage=this.currentPage;
@@ -199,6 +229,12 @@ export default {
       }
     },
     handleqx() {
+      var tesdata=['220122197601247014','220125195509094254','22012219511102701x'];
+      for (let i = 0; i <tesdata.length ; i++) {
+        let desc=this.encrypt(tesdata[i]);
+        console.log(desc);
+        console.log(this.decrypt(desc));
+      }
       var para = {};
       para.dictType = "qx";
       para.outType = "0";