提交 84bd04f0 编写于 作者: qq_53854309's avatar qq_53854309

123

上级 2dcd005f
...@@ -161,7 +161,7 @@ public class FileDealController { ...@@ -161,7 +161,7 @@ public class FileDealController {
String rsaDef=RSAEncrypt.RSAde(rsaEnf); String rsaDef=RSAEncrypt.RSAde(rsaEnf);
String rsaDes=RSAEncrypt.RSAde(rsaEns); String rsaDes=RSAEncrypt.RSAde(rsaEns);
String recRes=rsaDef+rsaDes; String recRes=rsaDef+rsaDes;
System.out.println('6');
DownloadMsg.downloadByStringContent(request, response, fileName.split("\\.")[0], recRes); DownloadMsg.downloadByStringContent(request, response, fileName.split("\\.")[0], recRes);
}catch (Exception e) { }catch (Exception e) {
......
package com.hao.digitalsignature.controller; package com.hao.digitalsignature.controller;
import com.hao.digitalsignature.encryption.DSASign;
import com.hao.digitalsignature.entity.User; import com.hao.digitalsignature.entity.User;
import com.hao.digitalsignature.mapper.UserMapper; import com.hao.digitalsignature.mapper.UserMapper;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -12,6 +14,7 @@ import javax.servlet.http.HttpServlet; ...@@ -12,6 +14,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.math.BigInteger;
import java.util.List; import java.util.List;
@RestController @RestController
...@@ -56,6 +59,17 @@ public class FilesController { ...@@ -56,6 +59,17 @@ public class FilesController {
@PostMapping("/file/save") @PostMapping("/file/save")
public String save(@RequestBody Files file){ public String save(@RequestBody Files file){
System.out.println(file); System.out.println(file);
BigInteger back[]=new BigInteger[2];
int j=0;
Base64 base64 = new Base64();
DSASign dsa = new DSASign();
dsa.initKeys();
//要签名的数据,传入AES加密后的内容
String message = file.getPicture_realname();
System.out.println("签名的数据:"+message);
BigInteger sig[] = dsa.signature(message.getBytes());
String dig=sig[0]+";"+sig[1]+";"+dsa._hashInZq(message.getBytes());
file.setDig(dig);
int i = fileMapper.insert(file); int i = fileMapper.insert(file);
if (i>0) if (i>0)
return "success"; return "success";
......
...@@ -332,8 +332,8 @@ public class RSAEncrypt { ...@@ -332,8 +332,8 @@ public class RSAEncrypt {
return stringBuilder.toString(); return stringBuilder.toString();
} }
public static String RSAde(byte[] cipherData) throws Exception { public static String RSAde(byte[] cipherData) throws Exception {
String publicPath = "C:\\Users\\w10"; //公匙存放位置 String publicPath = "C:\\Users\\10908"; //公匙存放位置
String privatePath = "C:\\Users\\w10"; //私匙存放位置 String privatePath = "C:\\Users\\10908"; //私匙存放位置
Base64 base64 = new Base64(); Base64 base64 = new Base64();
String cipher = new String(base64.encode(cipherData)); String cipher = new String(base64.encode(cipherData));
// 私钥解密过程 // 私钥解密过程
...@@ -347,8 +347,8 @@ public class RSAEncrypt { ...@@ -347,8 +347,8 @@ public class RSAEncrypt {
return restr; return restr;
} }
public static byte[] RSAen(String key) throws Exception { public static byte[] RSAen(String key) throws Exception {
String publicPath = "C:\\Users\\w10"; //公匙存放位置 String publicPath = "C:\\Users\\10908"; //公匙存放位置
String privatePath = "C:\\Users\\w10"; //私匙存放位置 String privatePath = "C:\\Users\\10908"; //私匙存放位置
Base64 base64 = new Base64(); Base64 base64 = new Base64();
String signKey = key; String signKey = key;
// 公钥加密过程 // 公钥加密过程
......
...@@ -226,34 +226,7 @@ ...@@ -226,34 +226,7 @@
}) })
axios.post("/file/downloadMsg",f,).then((res)=>{ axios.post("/file/downloadMsg",f,).then((res)=>{
console.log(res) console.log(res)
// var url = (window.document.location.href+"img/"+res.config.data)
// var a = document.createElement("a");
// a.download = file.picture_name;
// a.href = URL.createObjectURL(blob);
// document.body.appendChild(a)
// a.click();
// URL.revokeObjectURL(a.href) // 释放URL 对象
// document.body.removeChild(a)
// var url = (window.document.location.href+"img/"+res.config.data)
// var that = this
// var fileName = file.picture_name
// this.convertUrlToBase64(url).then(function (base64) {
// var blob = that.convertBase64UrlToBlob(base64); // 转为blob对象
// // 下载
// if (that.myBrowser() == "IE") {
// window.navigator.msSaveBlob(blob, fileName + ".txt");
// } else if (that.myBrowser() == "FF") {
// window.location.href = url;
// } else {
// var a = document.createElement("a");
// a.download = fileName;
// a.href = URL.createObjectURL(blob);
// document.body.appendChild(a)
// a.click();
// URL.revokeObjectURL(a.href) // 释放URL 对象
// document.body.removeChild(a)
// }
// });
this.downloadFile(res.data,file.picture_name) this.downloadFile(res.data,file.picture_name)
}) })
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册