Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_53854309
数字签名
提交
84bd04f0
数
数字签名
项目概览
qq_53854309
/
数字签名
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
数
数字签名
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
84bd04f0
编写于
4月 23, 2023
作者:
qq_53854309
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
123
上级
2dcd005f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
20 addition
and
33 deletion
+20
-33
src/main/java/com/hao/digitalsignature/controller/FileDealController.java
...m/hao/digitalsignature/controller/FileDealController.java
+1
-1
src/main/java/com/hao/digitalsignature/controller/FilesController.java
.../com/hao/digitalsignature/controller/FilesController.java
+14
-0
src/main/java/com/hao/digitalsignature/encryption/RSAEncrypt.java
.../java/com/hao/digitalsignature/encryption/RSAEncrypt.java
+4
-4
src/main/resources/static/index.html
src/main/resources/static/index.html
+1
-28
未找到文件。
src/main/java/com/hao/digitalsignature/controller/FileDealController.java
浏览文件 @
84bd04f0
...
@@ -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
)
{
...
...
src/main/java/com/hao/digitalsignature/controller/FilesController.java
浏览文件 @
84bd04f0
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"
;
...
...
src/main/java/com/hao/digitalsignature/encryption/RSAEncrypt.java
浏览文件 @
84bd04f0
...
@@ -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
;
// 公钥加密过程
// 公钥加密过程
...
...
src/main/resources/static/index.html
浏览文件 @
84bd04f0
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录