Skip to content

Commit b4cf604

Browse files
committed
1.5.1-preview3
1 parent 40a14cb commit b4cf604

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Senparc.CO2NET/Helpers/Strings/EncryptHelper.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ and limitations under the License.
5252
using System;
5353
using System.Collections.Generic;
5454
using System.IO;
55+
using System.IO.Pipes;
5556
using System.Linq;
5657
using System.Security.Cryptography;
5758
using System.Text;
@@ -137,6 +138,8 @@ public static string GetSha1(string encypStr, bool toUpper = true, Encoding enco
137138
/// <returns></returns>
138139
public static string GetSha1(Stream stream, bool toUpper = true, Encoding encoding = null)
139140
{
141+
stream.Seek(0, SeekOrigin.Begin);
142+
140143
var sha1 = SHA1.Create();
141144
var sha1Arr = sha1.ComputeHash(stream);
142145
StringBuilder enText = new StringBuilder();
@@ -287,7 +290,7 @@ public static string GetMD5(string encypStr, string charset = "utf-8")
287290
/// <returns></returns>
288291
public static string GetMD5(Stream stream, bool toUpper = true, Encoding encoding = null)
289292
{
290-
encoding = encoding ?? Encoding.UTF8;
293+
encoding ??= Encoding.UTF8;
291294
stream.Position = 0;
292295

293296
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();

0 commit comments

Comments
 (0)