-
-
Save parzibyte/326f90d14a3a3038a405e66d7c9bc6e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const desencriptar = async (contraseña, encriptadoEnBase64) => { | |
const decoder = new TextDecoder(); | |
const datosEncriptados = base64ABuffer(encriptadoEnBase64); | |
const sal = datosEncriptados.slice(0, LONGITUD_SAL); | |
const vectorInicializacion = datosEncriptados.slice(0 + LONGITUD_SAL, LONGITUD_SAL + LONGITUD_VECTOR_INICIALIZACION); | |
const clave = await derivacionDeClaveBasadaEnContraseña(contraseña, sal, 100000, 256, 'SHA-256'); | |
const datosDesencriptadosComoBuffer = await window.crypto.subtle.decrypt( | |
{ name: "AES-CBC", iv: vectorInicializacion }, | |
clave, | |
datosEncriptados.slice(LONGITUD_SAL + LONGITUD_VECTOR_INICIALIZACION) | |
); | |
return decoder.decode(datosDesencriptadosComoBuffer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment