Skip to content

Commit 5ffc0f2

Browse files
committed
credential create hash thread-safe added
1 parent 0fc7696 commit 5ffc0f2

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Core/Credential.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,29 @@ public CredentialType CredentialType
135135
/// <returns>encoded b64 hash</returns>
136136
public string CreateHash(string input)
137137
{
138+
if (string.IsNullOrEmpty(input))
139+
throw new ArgumentException("Input cannot be null or empty", nameof(input));
140+
138141
var inputBytes = Encoding.UTF8.GetBytes(input);
139142

140-
var hashBytes = CredentialSettings.HashAlgorithm.ComputeHash(inputBytes);
143+
using var hashAlgorithm = SHA1.Create();
141144

145+
var hashBytes = hashAlgorithm.ComputeHash(inputBytes);
142146
var encodedBytes = hashBytes.ToBase64String();
143147

144148
return encodedBytes;
145149
}
146150

151+
//public string CreateHash(string input)
152+
//{
153+
// var inputBytes = Encoding.UTF8.GetBytes(input);
154+
155+
// var hashBytes = CredentialSettings.HashAlgorithm.ComputeHash(inputBytes);
156+
157+
// var encodedBytes = hashBytes.ToBase64String();
158+
159+
// return encodedBytes;
160+
//}
147161

148162
/// <summary>
149163
/// Verify a hash against a string.

fiscalapi-credentials.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>net6.0;net8.0;net9.0</TargetFrameworks>
5-
<Version>4.0.95</Version>
5+
<Version>4.0.96</Version>
66
<AssemblyVersion>$(Version)</AssemblyVersion>
77
<FileVersion>$(Version)</FileVersion>
88
<PackageVersion>$(Version)</PackageVersion>

0 commit comments

Comments
 (0)