Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/NETCore.Encrypt/EncryptProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,11 +549,11 @@ private static byte[] DESDecrypt(byte[] data, string key, CipherMode cipherMode,
{
try
{
byte[] tmp = new byte[encryptedBytes.Length];
int len = cryptoStream.Read(tmp, 0, encryptedBytes.Length);
byte[] ret = new byte[len];
Array.Copy(tmp, 0, ret, 0, len);
return ret;
using (var outputStream = new MemoryStream())
{
cryptoStream.CopyTo(outputStream);
return outputStream.ToArray();
}
}
catch
{
Expand Down
8 changes: 4 additions & 4 deletions test/NETCore.Encrypt.Tests/DES_Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void DES_Encryt_EmptyData_Fail_Test()
public void DES_Encrypt_ErrorKey_Fail_Test()
{
var key = "1hyhuo";
var srcString = "test DES encrypt";
var srcString = "test DES encrypt -t";

//Assert
Assert.Throws<ArgumentException>(() => EncryptProvider.DESEncrypt(srcString, key));
Expand All @@ -51,7 +51,7 @@ public void DES_Encrypt_ErrorKey_Fail_Test()
[Fact(DisplayName = "DES decrypt success test")]
public void DES_Decryt_Success_Test()
{
var srcString = "test DES encrypt";
var srcString = "test DES encrypt -t";

//Ack
var encrypted = EncryptProvider.DESEncrypt(srcString, _Key);
Expand All @@ -67,7 +67,7 @@ public void DES_Decryt_Success_Test()
[Fact(DisplayName = "DES CBC mode decrypt success test")]
public void DES_CBCMode_Success_Test()
{
var srcString = "test DES encrypt";
var srcString = "test DES encrypt -t";

//Ack
var srsDatas = Encoding.UTF8.GetBytes(srcString);
Expand All @@ -93,7 +93,7 @@ public void DES_Decrypt_EmptyData_Fail_Test()
public void DES_Decrypt_ErrorKey_Fail_Test()
{
var key = "dfafa"; //must be 24 bit
var srcString = "test DES encrypt";
var srcString = "test DES encrypt -t";

//Assert
Assert.Throws<ArgumentException>(() => EncryptProvider.DESDecrypt(srcString, key));
Expand Down