Find Jobs
Hire Freelancers

Convert Encrypt / Decrypt PHP function to Node JS

$10-30 USD

Selesai
Dibuat lebih dari 9 tahun yang lalu

$10-30 USD

Dibayar ketika dikirim
I have no time to do it so I need someone to convert two functions from PHP code to Node JS. - Make this functions easy to use by creating a module so I can just do something like > var encdec = require('encdec'); < (this is not for redistribute, it is for a private project, so no need manuals nor any extras) and then I can just do > [login to view URL]('myEncryptedString'); < - This one returns a false on fail (which never happen) but try to do it error free as much as possible. /** * 256-bit decryption with mcrypt * MCRYPT_RIJNDAEL_128 is AES-compliant, and MCRYPT_MODE_CBC * Note: ECB mode is inadequate for many purposes because it does not use an IV * * @param string $encrypted receives the encrypted string to decrypt * return bool false on fail, or decrypted string if succeeded */ function myDecrypt ($encrypted) { // salt $salt = '!kqM*Ff7pXe1kBn%9'; // Build a 256-bit $key which is a SHA256 hash of $salt and $password. $key = hash('SHA256', $salt ."LPC9aVs3w8k45vx7oHOxZgoNus3banTGPp5wmhJ6hSnJko9rjB/G5Q1mdhdxjm01q6kK2h44MP5L6DML4nY/uq", true); // Retrieve $iv which is the first 22 characters plus ==, base64_decoded. $iv = base64_decode(substr($encrypted, 0, 22) . '=='); // Remove $iv from $encrypted. $encrypted = substr($encrypted, 22); // Decrypt the data. rtrim won't corrupt the data because the last 32 characters are the md5 hash; thus any \0 character has to be padding. @$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, base64_decode($encrypted), MCRYPT_MODE_CBC, $iv), "\0\4"); // Retrieve $hash which is the last 32 characters of $decrypted. $hash = substr($decrypted, - 32); // Remove the last 32 characters from $decrypted. $decrypted = substr($decrypted, 0, - 32); // Integrity check. If this fails, either the data is corrupted, or the password/salt was incorrect. if (md5($decrypted) != $hash) return false; // Yay! return $decrypted; } /** * 256-bit encryption with mcrypt * MCRYPT_RIJNDAEL_128 is AES-compliant, and MCRYPT_MODE_CBC * Note: ECB mode is inadequate for many purposes because it does not use an IV * * @param string $decrypted receives the unencrypted string to encrypt * return bool false on fail, or encrypted string if succeeded */ function myEncrypt($decrypted) { // salt $salt = '!kqM*Ff7pXe1kBn%9'; // Build a 256-bit $key which is a SHA256 hash of $salt and $password. $key = hash('SHA256', $salt ."LPC9aVs3w8k45vx7oHOxZgoNus3banTGPp5wmhJ6hSnJko9rjB/G5Q1mdhdxjm01q6kK2h44MP5L6DML4nY/uq", true); // Build $iv and $iv_base64. We use a block size of 128 bits (AES compliant) and CBC mode. (Note: ECB mode is inadequate as IV is not used.) srand(); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND); if (strlen($iv_base64 = rtrim(base64_encode($iv), '=')) != 22) return false; // Encrypt $decrypted and an MD5 of $decrypted using $key. MD5 is fine to use here because it's just to verify successful decryption. $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $decrypted . md5($decrypted), MCRYPT_MODE_CBC, $iv)); // We're done! return $iv_base64 . $encrypted; }
ID Proyek: 6323804

Tentang proyek

6 proposal
Proyek remot
Aktif 10 tahun yang lalu

Ingin menghasilkan uang?

Keuntungan menawar di Freelancer

Tentukan anggaran dan garis waktu Anda
Dapatkan bayaran atas pekerjaan Anda
Uraikan proposal Anda
Gratis mendaftar dan menawar pekerjaan
Diberikan kepada:
Avatar Pengguna
Hi, after reading your requirements i decided to place a bid on this project. I lead a team of node.js development. My total experience in node.js is around three years. overall IT experience is 7 years. We have experienced team of experts of Node.js, html designers, mongodb and web applications. We can discuss more on skype username 'morwal89'. Hope to hear back. Thank you.
$35 USD dalam 1 hari
5,0 (1 ulasan)
1,8
1,8
6 freelancer menawar dengan rata-rata $43 USD untuk pekerjaan ini
Avatar Pengguna
一个有效的提议尚未被提供
$30 USD dalam 1 hari
0,0 (0 ulasan)
0,0
0,0
Avatar Pengguna
Hello, The task is trivial. I will create a node module (wrapper over crypto module) which exports two functions: encrypt and decrypt. I have a 4 years experience in designing complex software using python and nodejs. Thank you and good luck!
$30 USD dalam 1 hari
0,0 (0 ulasan)
0,0
0,0
Avatar Pengguna
I am a highly experienced developer and very familiar with javascript and node.js Your task is straight-forward and I will complete it very quickly with unit tests included.
$45 USD dalam 1 hari
0,0 (0 ulasan)
0,0
0,0

Tentang klien

Bendera UNITED ARAB EMIRATES
dxb, United Arab Emirates
5,0
1
Memverifikasi Metode pembayaran
Anggota sejak Jul 15, 2014

Verifikasi Klien

Terima kasih! Kami telah mengirim Anda email untuk mengklaim kredit gratis Anda.
Anda sesuatu yang salah saat mengirimkan Anda email. Silakan coba lagi.
Pengguna Terdaftar Total Pekerjaan Terpasang
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Memuat pratinjau
Izin diberikan untuk Geolokasi.
Sesi login Anda telah kedaluwarsa dan Anda sudah keluar. Silakan login kembali.