diff options
author | chai <215380520@qq.com> | 2023-05-16 08:50:55 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2023-05-16 08:50:55 +0800 |
commit | 27df4282109a26a21aa042793c3136fbb5b81a98 (patch) | |
tree | fb20d2b3b6270430eaa32de9a0c88aa7ea5d8258 /WorldlineKeepers/Assets/Scripts/Utils/StringUtils.cs | |
parent | 85629d871b1cbf65e57c8e25b2145c0b77f7e353 (diff) |
*misc
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(); + } + + } + +} |