Skip to content

Instantly share code, notes, and snippets.

@jofese
Created August 10, 2017 16:12
Show Gist options
  • Save jofese/81e24f1a2535152211494beaf3415218 to your computer and use it in GitHub Desktop.
Save jofese/81e24f1a2535152211494beaf3415218 to your computer and use it in GitHub Desktop.
public static string CifrarClave(string clave)
{
//Declaramos un Objeto de tipo SHA512Managed
SHA512Managed passwd = new SHA512Managed();
//Declarmos un arreglo bytes donde se guardara el texto a cifrar en formato de bytes
byte[] texto = System.Text.Encoding.ASCII.GetBytes(clave);
//Declaramos otro arrego de bytes donde se guardará la contraseña ya cifrada.
byte[] textocifrado = passwd.ComputeHash(texto);
//convertimo en texto lo bytes cifrado
string contrasena = Convert.ToBase64String(textocifrado);
//regresamos la contraseña cifrada
return contrasena;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment