_getEncryptedPassword() { const { assetPassword, encryptionKey } = this.config; if (!assetPassword || !encryptionKey) { return ''; } const key = Buffer.from(encryptionKey, 'base64'); const iv = randomBytes(16); const cipher = crypto.createCipheriv('aes-256-cbc', key, iv); return `${iv.toString('hex')}${cipher.update(assetPassword, 'utf8', 'hex')}${cipher.final( 'hex' )}`.toUpperCase(); }
throw new DataError('Invalid AES-CBC and length pair.') let cipher = crypto.createCipheriv(cipherName,key.handle,Buffer.from(algorithm.iv)) let ciphertext = cipher.update(Buffer.from(data))
cipher = crypto.createCipheriv(cipherName,wrappingKey.handle,iv) ciphertext = cipher.update(data) } catch (error) {
throw new DataError('Invalid AES-CTR and length pair.') let cipher = crypto.createCipheriv(cipherName,key.handle,Buffer.from(algorithm.counter))
throw new DataError('Invalid AES-GCM and length pair.') let cipher = crypto.createCipheriv(cipherName,key.handle,Buffer.from(algorithm.iv)) cipher.setAAD(additionalData) let ciphertext = cipher.update(Buffer.from(data))
_getEncryptedPassword() { const { assetPassword, encryptionKey } = this.config; if (!assetPassword || !encryptionKey) { return ''; } const key = Buffer.from(encryptionKey, 'base64'); const iv = randomBytes(16); const cipher = crypto.createCipheriv('aes-256-cbc', key, iv); return `${iv.toString('hex')}${cipher.update(assetPassword, 'utf8', 'hex')}${cipher.final( 'hex' )}`.toUpperCase(); }