본문 바로가기

.NET/C#

c# asp.net SHA256 256bit 암호화

      // SHA256  256bit 암호화

        public string SHA256Hash(string text, string salt, System.Security.Cryptography.HashAlgorithm hasher)

        {

            byte[] textWithSaltBytes = Encoding.UTF8.GetBytes(string.Concat(text, salt));

            byte[] hashedBytes = hasher.ComputeHash(textWithSaltBytes);

            hasher.Clear();

            return Convert.ToBase64String(hashedBytes);

        }


        public string GetPassword(string input)

        {

            return SHA256Hash(input, "salt값.", new SHA1CryptoServiceProvider());

        }