Red de conocimiento informático - Conocimiento del nombre de dominio - Cómo utilizar el cifrado js sha512

Cómo utilizar el cifrado js sha512

Cómo utilizar el cifrado js sha512:

1. Primero vaya a git para descargar sha512.js e introduzca la página que desea llamar.

2. Después de llamar a este método, escriba el siguiente código js en la etiqueta del script entre head y

function calcHash() {

intente {

var hashInput = document.getElementById("hashInputType");

var hashVariant = document.getElementById("hashVariant");

var hashRounds = document.getElementById("hashRounds");

var hashOutputType = document.getElementById("hashOutputType");

var hashOutput = document.getElementById("hashOutputText"); >

var hashObj = new jsSHA(

hashVariant.options[hashVariant.selectedIndex].value,

hashInputType.options[hashInputType.selectedIndex].value,

{ numRounds: parseInt(hashRounds.value, 10)}

hashObj.update(hashInput.value

hashOutput.value); = hashObj.getHash( hashOutputType.options[hashOutputType.selectedIndex].value);

} catch(e) {

hashOutput.value = e.message

}

}

función calcHMAC() {

prueba {

var hmacText = document.getElementById("hmacInputText ");

var hmacTextType = document.getElementById("hmacInputKey");

var hmacKeyInputType = document.getElementById("hmacVariant");

var hmacOutputType = documento. getElementById("hmacOutputType");

var hmacOutput = document.getElementById("hmacOutputText");

var hmacObj = new jsSHA(

hmacVariant .options[ hmacVariant.selectedIndex].value,

hmacTextType.options[hmacTextType.selectedIndex].v

alue

);

hmacObj.setHMACKey(

hmacKeyInput.value,

hmacKeyInputType.options[hmacKeyInputType.selectedIndex].value

);

hmacObj.update(hmacText.value);

hmacOutput.value = hmacObj.getHMAC(hmacOutputType.options[hmacOutputType.selectedIndex].value) ;

} captura(e) {

hmacOutput.value = e.message

}

}

Entre ellos, jsSHA es un método que se ha implementado en sha512.js.