Find Jobs
Hire Freelancers

Convert Encrypt / Decrypt PHP function to Node JS

$10-30 USD

Terminado
Publicado hace más de 9 años

$10-30 USD

Pagado a la entrega
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 del proyecto: 6323804

Información sobre el proyecto

6 propuestas
Proyecto remoto
Activo hace 10 años

¿Buscas ganar dinero?

Beneficios de presentar ofertas en Freelancer

Fija tu plazo y presupuesto
Cobra por tu trabajo
Describe tu propuesta
Es gratis registrarse y presentar ofertas en los trabajos
Adjudicado a:
Avatar del usuario
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 en 1 día
5,0 (1 comentario)
1,8
1,8
6 freelancers están ofertando un promedio de $43 USD por este trabajo
Avatar del usuario
一个有效的提议尚未被提供
$30 USD en 1 día
0,0 (0 comentarios)
0,0
0,0
Avatar del usuario
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 en 1 día
0,0 (0 comentarios)
0,0
0,0
Avatar del usuario
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 en 1 día
0,0 (0 comentarios)
0,0
0,0

Sobre este cliente

Bandera de UNITED ARAB EMIRATES
dxb, United Arab Emirates
5,0
1
Forma de pago verificada
Miembro desde jul 15, 2014

Verificación del cliente

¡Gracias! Te hemos enviado un enlace para reclamar tu crédito gratuito.
Algo salió mal al enviar tu correo electrónico. Por favor, intenta de nuevo.
Usuarios registrados Total de empleos publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Cargando visualización previa
Permiso concedido para Geolocalización.
Tu sesión de acceso ha expirado y has sido desconectado. Por favor, inica sesión nuevamente.