Commit 70be7f7e by 何阳

fix: 1. 传入了空密码导致报错 2. 修复了先进语法不兼容的问题

parent 949fdfe0
......@@ -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 StreamReader streamReader = new StreamReader(stream2);
var stream = new MemoryStream(buffer);
var stream2 = new CryptoStream(stream, transform, CryptoStreamMode.Read);
var streamReader = new StreamReader(stream2);
return streamReader.ReadToEnd().TrimEnd(default(char));
}
}
......
......@@ -151,7 +151,7 @@ namespace FaceServer.Server
{
Log.Information("进入密码加密模式");
// MD5加密并转小写
var hash = EncryptionHelper.GetMD5String(user.password).ToLower();
var hash = EncryptionHelper.GetMD5String(Config.Passwd).ToLower();
Log.Information($"加密后={hash}");
user.password = hash;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment