Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
何阳
/
FaceApp
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
70be7f7e
authored
Jun 05, 2024
by
何阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix: 1. 传入了空密码导致报错 2. 修复了先进语法不兼容的问题
parent
949fdfe0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
FaceServer/Server/EncryptionHelper.cs
FaceServer/Server/FaceDataSet.cs
FaceServer/Server/EncryptionHelper.cs
View file @
70be7f7e
...
...
@@ -92,15 +92,15 @@ namespace FaceServer.Server
return
toEncrypt
;
}
using
RijndaelManaged
rijndaelManaged
=
new
RijndaelManaged
();
var
rijndaelManaged
=
new
RijndaelManaged
();
rijndaelManaged
.
Mode
=
CipherMode
.
CBC
;
rijndaelManaged
.
Padding
=
PaddingMode
.
Zeros
;
rijndaelManaged
.
FeedbackSize
=
128
;
rijndaelManaged
.
Key
=
Encoding
.
UTF8
.
GetBytes
(
key
);
rijndaelManaged
.
IV
=
Encoding
.
UTF8
.
GetBytes
(
iv
);
ICryptoTransform
transform
=
rijndaelManaged
.
CreateEncryptor
(
rijndaelManaged
.
Key
,
rijndaelManaged
.
IV
);
using
MemoryStream
memoryStream
=
new
MemoryStream
();
using
CryptoStream
stream
=
new
CryptoStream
(
memoryStream
,
transform
,
CryptoStreamMode
.
Write
);
var
memoryStream
=
new
MemoryStream
();
var
stream
=
new
CryptoStream
(
memoryStream
,
transform
,
CryptoStreamMode
.
Write
);
using
(
StreamWriter
streamWriter
=
new
StreamWriter
(
stream
))
{
streamWriter
.
Write
(
toEncrypt
);
...
...
@@ -118,16 +118,16 @@ namespace FaceServer.Server
}
byte
[]
buffer
=
Convert
.
FromBase64String
(
toDecrypt
);
using
RijndaelManaged
rijndaelManaged
=
new
RijndaelManaged
();
var
rijndaelManaged
=
new
RijndaelManaged
();
rijndaelManaged
.
Mode
=
CipherMode
.
CBC
;
rijndaelManaged
.
Padding
=
PaddingMode
.
Zeros
;
rijndaelManaged
.
FeedbackSize
=
128
;
rijndaelManaged
.
Key
=
Encoding
.
UTF8
.
GetBytes
(
key
);
rijndaelManaged
.
IV
=
Encoding
.
UTF8
.
GetBytes
(
iv
);
ICryptoTransform
transform
=
rijndaelManaged
.
CreateDecryptor
(
rijndaelManaged
.
Key
,
rijndaelManaged
.
IV
);
using
MemoryStream
stream
=
new
MemoryStream
(
buffer
);
using
CryptoStream
stream2
=
new
CryptoStream
(
stream
,
transform
,
CryptoStreamMode
.
Read
);
using
StreamReade
r
streamReader
=
new
StreamReader
(
stream2
);
var
stream
=
new
MemoryStream
(
buffer
);
var
stream2
=
new
CryptoStream
(
stream
,
transform
,
CryptoStreamMode
.
Read
);
va
r
streamReader
=
new
StreamReader
(
stream2
);
return
streamReader
.
ReadToEnd
().
TrimEnd
(
default
(
char
));
}
}
...
...
FaceServer/Server/FaceDataSet.cs
View file @
70be7f7e
...
...
@@ -151,7 +151,7 @@ namespace FaceServer.Server
{
Log
.
Information
(
"进入密码加密模式"
);
// MD5加密并转小写
var
hash
=
EncryptionHelper
.
GetMD5String
(
user
.
passwor
d
).
ToLower
();
var
hash
=
EncryptionHelper
.
GetMD5String
(
Config
.
Passw
d
).
ToLower
();
Log
.
Information
(
$"加密后=
{
hash
}
"
);
user
.
password
=
hash
;
}
...
...
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