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
// node 13-MetaMask_encrypt_decrypt.js | |
const crypto = require('crypto'); | |
// Функция для извлечения значения между двумя ключами | |
function extractValueBetweenKeys(data, startKey, endKey) { | |
const regex = new RegExp(`${startKey}(.*?)${endKey}`, 's'); | |
const match = data.match(regex); | |
return match ? match[1] : null; | |
} |
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
// node 0-SECURE_encrypt_decrypt_data.js | |
const crypto = require('crypto'); | |
//Шифрование | |
function encrypt(data, password) { | |
// Генерация salt для уникальности шифрованого пароля | |
const salt = crypto.randomBytes(16); | |
// Создание ключа из пароля (длиной 32 байта) |