Pregunta

Ok i want to generate a sha1 hash from plaintext textbox then convert the hash to base64 to store in a mysql database how do i do it?

¿Fue útil?

Solución

        string s = "abc";
        byte[] data = Encoding.Unicode.GetBytes(s);
        SHA1 algorithm = SHA1.Create();
        byte[] hash = algorithm.ComputeHash(data);
        string base64 = Convert.ToBase64String(hash);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top