Find Jobs
Hire Freelancers

Convert Encrypt / Decrypt PHP function to Node JS

$10-30 USD

Ολοκληρώθηκε
Αναρτήθηκε πάνω από 9 χρόνια πριν

$10-30 USD

Πληρωμή κατά την παράδοση
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; }
Ταυτότητα εργασίας: 6323804

Σχετικά με την εργασία

6 προτάσεις
Απομακρυσμένη Εργασία
Ενεργός/ή 10 χρόνια πριν

Ψάχνεις τρόπο για να κερδίσεις μερικά χρήματα;

Πλεονεκτήματα πλειοδοσίας στο Freelancer

Καθόρισε τον προϋπολογισμό σου και το χρονοδιάγραμμα
Πληρώσου για τη δουλειά σου
Περίγραψε την πρόταση σου
Η εγγραφή και η πλειοδοσία σε εργασίες είναι δωρεάν
Βραβεύτηκε στον/στην:
Avatar Χρήστη
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 σε 1 ημέρα
5,0 (1 αξιολόγηση)
1,8
1,8
6 freelancers δίνουν μια μέση προσφορά $43 USD για αυτή τη δουλειά
Avatar Χρήστη
一个有效的提议尚未被提供
$30 USD σε 1 ημέρα
0,0 (0 αξιολογήσεις)
0,0
0,0
Avatar Χρήστη
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 σε 1 ημέρα
0,0 (0 αξιολογήσεις)
0,0
0,0
Avatar Χρήστη
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 σε 1 ημέρα
0,0 (0 αξιολογήσεις)
0,0
0,0

Σχετικά με τον πελάτη

Σημαία της UNITED ARAB EMIRATES
dxb, United Arab Emirates
5,0
1
Επαληθευμένη μέθοδος πληρωμής
Μέλος από Ιουλ 15, 2014

Επαλήθευση Πελάτη

Ευχαριστούμε! Σου έχουμε στείλει ένα email με ένα σύνδεσμο για να διεκδικήσεις τη δωρεάν πίστωση σου.
Κάτι πήγε στραβά κατά την προσπάθεια αποστολής του email σου. Παρακαλούμε δοκίμασε ξανά.
Εγγεγραμμένοι Χρήστες Συνολικές Αναρτημένες Δουλειές
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Φόρτωση προεπισκόπησης
Δόθηκε πρόσβαση για Geolocation.
Η σύνδεση σου έχει λήξει και τώρα έχεις αποσυνδεθεί. Παρακαλούμε συνδέσου ξανά.