mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-01 01:38:39 +00:00
Go against Rider's wishes and not use var
This commit is contained in:
parent
a2b6908c07
commit
a903741276
1 changed files with 8 additions and 8 deletions
|
@ -51,27 +51,27 @@ namespace LBPUnion.ProjectLighthouse.Helpers {
|
||||||
public static async Task<string> ComputeDigest(string path, string authCookie, Stream body,
|
public static async Task<string> ComputeDigest(string path, string authCookie, Stream body,
|
||||||
string digestKey)
|
string digestKey)
|
||||||
{
|
{
|
||||||
var memoryStream = new MemoryStream();
|
MemoryStream memoryStream = new MemoryStream();
|
||||||
|
|
||||||
var pathBytes = Encoding.UTF8.GetBytes(path);
|
byte[] pathBytes = Encoding.UTF8.GetBytes(path);
|
||||||
var cookieBytes = string.IsNullOrEmpty(authCookie)
|
byte[] cookieBytes = string.IsNullOrEmpty(authCookie)
|
||||||
? Array.Empty<byte>()
|
? Array.Empty<byte>()
|
||||||
: Encoding.UTF8.GetBytes(authCookie);
|
: Encoding.UTF8.GetBytes(authCookie);
|
||||||
var keyBytes = Encoding.UTF8.GetBytes(digestKey);
|
byte[] keyBytes = Encoding.UTF8.GetBytes(digestKey);
|
||||||
|
|
||||||
await body.CopyToAsync(memoryStream);
|
await body.CopyToAsync(memoryStream);
|
||||||
|
|
||||||
var bodyBytes = memoryStream.ToArray();
|
byte[] bodyBytes = memoryStream.ToArray();
|
||||||
|
|
||||||
using var sha1 = IncrementalHash.CreateHash(HashAlgorithmName.SHA1);
|
using IncrementalHash sha1 = IncrementalHash.CreateHash(HashAlgorithmName.SHA1);
|
||||||
sha1.AppendData(bodyBytes);
|
sha1.AppendData(bodyBytes);
|
||||||
if (cookieBytes.Length > 0)
|
if (cookieBytes.Length > 0)
|
||||||
sha1.AppendData(cookieBytes);
|
sha1.AppendData(cookieBytes);
|
||||||
sha1.AppendData(pathBytes);
|
sha1.AppendData(pathBytes);
|
||||||
sha1.AppendData(keyBytes);
|
sha1.AppendData(keyBytes);
|
||||||
|
|
||||||
var digestBytes = sha1.GetHashAndReset();
|
byte[] digestBytes = sha1.GetHashAndReset();
|
||||||
var digestString = Convert.ToHexString(digestBytes).ToLower();
|
string digestString = Convert.ToHexString(digestBytes).ToLower();
|
||||||
|
|
||||||
return digestString;
|
return digestString;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue