diff options
Diffstat (limited to 'WorldlineKeepers/Assets/Scripts/Utils/StringUtils.cs')
-rw-r--r-- | WorldlineKeepers/Assets/Scripts/Utils/StringUtils.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/WorldlineKeepers/Assets/Scripts/Utils/StringUtils.cs b/WorldlineKeepers/Assets/Scripts/Utils/StringUtils.cs new file mode 100644 index 0000000..b9ec52e --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Utils/StringUtils.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using System.Security.Cryptography; +using System.Text; +using UnityEngine; + +namespace WK.Utils +{ + + public class StringUtils + { + + public static byte[] GetHash(string inputString) + { + using (HashAlgorithm algorithm = SHA256.Create()) + return algorithm.ComputeHash(Encoding.UTF8.GetBytes(inputString)); + } + + public static string GetHashString(string inputString) + { + StringBuilder sb = new StringBuilder(); + foreach (byte b in GetHash(inputString)) + sb.Append(b.ToString("X2")); + + return sb.ToString(); + } + + } + +} |