Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
455d0861
Commit
455d0861
authored
Jun 05, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
非对称加密封装
parent
66f5b89b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
0 deletions
+52
-0
RSAHelper.cs
Mall.Common/Plugin/RSAHelper.cs
+51
-0
AppletUserController.cs
Mall.WebApi/Controllers/User/AppletUserController.cs
+1
-0
No files found.
Mall.Common/Plugin/RSAHelper.cs
0 → 100644
View file @
455d0861
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Reflection
;
using
System.Security.Cryptography
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Mall.Common.Plugin
{
/// <summary>
/// 枚举帮助类
/// </summary>
public
class
RSAHelper
{
//Erp公钥
static
string
TargetPublicKey
=
@"<RSAKeyValue><Modulus>qr3Hipzvvn9dsFn1juGEM5vHiYl4whHnJ7DFqC4ZVAotL0bRCZd7vWvPl53AJY9p8u2hNgPP3J6/I5NairyCiizW++8kCPue1Lpq9qc9ueBwij1bo5Sqi1nswpJsKyd9kOD5aOzqrnuhKTLYMZN9fkHl3L4wjpuVz1xlTgpYdxc=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"
;
//小程序私钥
//static string PublicKey = @"<RSAKeyValue><Modulus>4W8WliHbSkVE20kIze0KvCIOJgwG4PSRHHb6LNjc3smttrU952pGFi7g7dly1tj+oNUpCB5Ba5a1EUQI9vlfCXUYRICdiNneW6T78BFED5x8HZp8JUCMeatD8wFrKPVV4twaj2QtqGsTw60ZVmVFzHi/eNLVBYvfnzKCGCp0dG8=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
static
string
PrivateKey
=
@"<RSAKeyValue><Modulus>4W8WliHbSkVE20kIze0KvCIOJgwG4PSRHHb6LNjc3smttrU952pGFi7g7dly1tj+oNUpCB5Ba5a1EUQI9vlfCXUYRICdiNneW6T78BFED5x8HZp8JUCMeatD8wFrKPVV4twaj2QtqGsTw60ZVmVFzHi/eNLVBYvfnzKCGCp0dG8=</Modulus><Exponent>AQAB</Exponent><P>97qvHs/ptDJiw+FGvqvNLOJX1TJPbed9sfNNEhAZe+x/XPQfnzu0IxEkIxH/BL29gVryWExH8b/ZcgQuXCpUsw==</P><Q>6PXZPVntcKdo4ZlbQAU/+VI47rAZGkNtW/w25UVGrVC31Zc3GSqCVlKZgccRe6/PLrjOUBKDRYiYd3Yj+azXVQ==</Q><DP>ciyzW3Md1jRGutrQHT7XUHF9Y8BNRW0kzGhDRCjxZeEpDjFhhaUhr+vNiPBZZdkBR2YgPbviiLQQRvFQYKAN6w==</DP><DQ>AgBSrG9AVe5qPT3nBcbFxOuK56oFnS8lGlwxUIjm0YhW+/O/mmy+D+XHwdCm+swI2Jrn0tJF5GwG+0e9iWCNvQ==</DQ><InverseQ>WsKgSM0RiMFpXGoyL8bqZi2q1MAB+iz4WXPcL/OmHKluo8wuK/Pk+zOKkyjMO91tKXhjLOd7xpVb1AIsk/fAeQ==</InverseQ><D>daiCNFd1WZ0vo/fJZZkLWke39LmgOXbL6fxa9F83X/wI82xC4+4+qENNWDZ+zo2w0AaRBNCtulaNKHbG6wgaRh15yuOHkr90oydquHHPUqCjFWnIEYx2NnX85HtyBTwowCeePajCTsEi6vMRgKlBCIFWxqc6z5To1lTgfqtKb8k=</D></RSAKeyValue>"
;
static
RSACryptoServiceProvider
rsaProvider
=
new
RSACryptoServiceProvider
(
1024
);
public
static
byte
[]
EncryptData
(
byte
[]
data
)
{
RSACryptoServiceProvider
rsa
=
new
RSACryptoServiceProvider
(
1024
);
//将公钥导入到RSA对象中,准备加密;
rsa
.
FromXmlString
(
TargetPublicKey
);
//对数据data进行加密,并返回加密结果;
//第二个参数用来选择Padding的格式
byte
[]
buffer
=
rsa
.
Encrypt
(
data
,
false
);
return
buffer
;
}
public
static
byte
[]
DecryptData
(
byte
[]
data
)
{
RSACryptoServiceProvider
rsa
=
new
RSACryptoServiceProvider
(
1024
);
//将私钥导入RSA中,准备解密;
rsa
.
FromXmlString
(
PrivateKey
);
//对数据进行解密,并返回解密结果;
return
rsa
.
Decrypt
(
data
,
false
);
}
}
}
Mall.WebApi/Controllers/User/AppletUserController.cs
View file @
455d0861
...
...
@@ -568,6 +568,7 @@ namespace Mall.WebApi.Controllers.User
pagelist
.
pageData
=
list
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
GoodsId
,
x
.
GoodsName
,
x
.
GoodsImgPath
,
x
.
Price
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment