-
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.
Merge pull request #2 from OpenAbility/dev
Merge the latest changes
- Loading branch information
Showing
4 changed files
with
185 additions
and
51 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
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,31 @@ | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
||
namespace ContentPipe; | ||
|
||
internal static class Extras | ||
{ | ||
public static string ReadTerminatedString(this BinaryReader reader) | ||
{ | ||
string s = ""; | ||
char c; | ||
while ((c = reader.ReadChar()) != '\0') | ||
s += c; | ||
return s; | ||
} | ||
|
||
public static byte[] GetHash(this string inputString) | ||
{ | ||
using (HashAlgorithm algorithm = SHA256.Create()) | ||
return algorithm.ComputeHash(Encoding.UTF8.GetBytes(inputString)); | ||
} | ||
|
||
public static string GetHashString(this string inputString) | ||
{ | ||
StringBuilder sb = new StringBuilder(); | ||
foreach (byte b in GetHash(inputString)) | ||
sb.Append(b.ToString("X2")); | ||
|
||
return sb.ToString(); | ||
} | ||
} |
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