using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; using System.Security; using System.Text; using System.Threading.Tasks; namespace PaymentLogs.Utils { internal class StringUtils { public static SecureString ConvertToSecureString(string password) { if (password == null) throw new ArgumentNullException(""); var securePassword = new SecureString(); foreach (char c in password) securePassword.AppendChar(c); securePassword.MakeReadOnly(); return securePassword; } public static String SecureStringToString(SecureString value) { return new System.Net.NetworkCredential("qwq112", value).Password; } public static string SHA256_hash(string _value) { var crypt = new SHA256Managed(); string hash = String.Empty; byte[] crypto = crypt.ComputeHash(Encoding.UTF8.GetBytes(_value)); foreach (byte theByte in crypto) { hash += theByte.ToString("x2"); } return hash; } } }