-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the ability to hash the key. Can be used for long keys.
- Loading branch information
1 parent
89725b0
commit 3c33e47
Showing
3 changed files
with
122 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Security.Cryptography; | ||
|
||
namespace CacheDrive.Services; | ||
|
||
internal static class HashString | ||
{ | ||
public static string HashKey(string key) | ||
{ | ||
// Convert the string to a byte array first, to be processed | ||
var textBytes = System.Text.Encoding.UTF8.GetBytes(key); | ||
var hashBytes = SHA256.HashData(textBytes); | ||
|
||
// Convert back to a string, removing the '-' that BitConverter adds | ||
return BitConverter.ToString(hashBytes).Replace("-", string.Empty); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters