-
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.
- Loading branch information
1 parent
f715e75
commit 609ea19
Showing
2 changed files
with
28 additions
and
2 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
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,26 @@ | ||
// Copyright (c) Hannes Barbez. All rights reserved. | ||
// Licensed under the GNU General Public License v3.0 | ||
|
||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
||
namespace BarbezDotEu.Byte | ||
{ | ||
/// <summary> | ||
/// Helpers for cryptography. | ||
/// </summary> | ||
public static class CryptoHelper | ||
{ | ||
/// <summary> | ||
/// Equivalent of T-SQL's HASHBYTES('SHA2_256', <toHash>)". | ||
/// </summary> | ||
/// <param name="toHash">The string to hash.</param> | ||
/// <returns>The result of the hash.</returns> | ||
public static byte[] GetTsqlLikeHashBytes(string toHash) | ||
{ | ||
byte[] hashable = Encoding.Unicode.GetBytes(toHash); | ||
var hasher = SHA256.Create(); | ||
return hasher.ComputeHash(hashable); | ||
} | ||
} | ||
} |