-
-
Save parzibyte/0c01a6361330a6f9efc79c731b87cf24 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 derivacionDeClaveBasadaEnContraseña = async (contraseña, sal, iteraciones, longitud, hash, algoritmo = 'AES-CBC') => { | |
const encoder = new TextEncoder(); | |
let keyMaterial = await window.crypto.subtle.importKey( | |
'raw', | |
encoder.encode(contraseña), | |
{ name: 'PBKDF2' }, | |
false, | |
['deriveKey'] | |
); | |
return await window.crypto.subtle.deriveKey( | |
{ | |
name: 'PBKDF2', | |
salt: encoder.encode(sal), | |
iterations: iteraciones, | |
hash | |
}, | |
keyMaterial, | |
{ name: algoritmo, length: longitud }, | |
false, | |
['encrypt', 'decrypt'] | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment