nl_tokens: Encrypt a private key for mobile apps ( AES_PBKF2 )
pl_tokens: function ( password , privateKey ) { // Errors if ( ! password || ! privateKey ) throw <mask> Error ( 'Missing argument !' ) ; //if (!Helpers.isPrivateKeyValid(privateKey)) throw new Error('Private key is not valid !'); // Processing let salt = CryptoJS . lib . WordArray . random ( 256 / 8 ) ; let key = CryptoJS . PBKDF2 ( password , salt , { keySize : 256 / 32 , iterations : 2000 } ) ; let iv = nacl . randomBytes ( 16 ) let encIv = { iv : ua2words ( iv , 16 ) } ; let encrypted = CryptoJS . AES . encrypt ( CryptoJS . enc . Hex . parse ( privateKey ) , key , encIv ) ; // Result return { encrypted : convert . uint8ToHex ( iv ) + encrypted . ciphertext , salt : salt . toString ( ) } }