emn178/js-sha256

Using Salt

Closed this issue · 1 comments

What should I do if I want to use salt?

function makeSalt(length: number): string {
    const possibleChar = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890'.split('')
    let salt = '';

    for(let i = 0; i < length; i++) {
        salt += possibleChar[Math.floor(Math.random() * possibleChar.length)];
    }

    return salt;
}