src/crypto/cryptoHelpers.js
function(privateKey, password) {
    // Errors
    if (!privateKey || !password) throw new Error('Missing argument !');
    if (!Helpers.isPrivateKeyValid(privateKey)) throw new Error('Private key is not valid !');
    // Processing
    let pass = derivePassSha(password, 20);
    let r = encrypt(privateKey, convert.hex2ua(pass.priv));
    // Result
    return {
        ciphertext: CryptoJS.enc.Hex.stringify(r.ciphertext),
        iv: convert.ua2hex(r.iv)
    };
}
function(privateKey, password) {
    // Errors
    if (!privateKey || !password) throw new Error('Missing argument !');
    if (!Helpers.isPrivateKeyValid(privateKey)) throw new Error('Private key is not valid !');
    // Processing
    let pass = derivePassSha(password, 20);
    let r = encrypt(privateKey, convert.hex2ua(pass.priv));
    // Result
    return {
        ciphertext: CryptoJS.enc.Hex.stringify(r.ciphertext),
        iv: convert.ua2hex(r.iv)
    };
}
function ( privateKey , password ) { // Errors if ( ! privateKey || ! password ) throw new Error ( 'Missing argument !' ) ; if ( ! Helpers . isPrivateKeyValid ( privateKey ) ) throw new Error ( 'Private key is not valid !' ) ; // Processing let pass = derivePassSha ( password , 20 ) ; let r = encrypt ( privateKey , convert . hex2ua ( pass . priv ) ) ; // Result return { ciphertext : CryptoJS . enc . Hex . stringify ( r . ciphertext ) , iv : convert . ua2hex ( r . iv ) } ; }
Encode a private key using a password

@param {string} privateKey - An hex private key
@param {string} password - A password

@return {object} - The encoded data
Encode a private key using a password