•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,543 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,305 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1982 | Replies: 3
![]() |
•
•
Join Date: Jul 2007
Posts: 23
Reputation:
Rep Power: 2
Solved Threads: 3
I am currently building an online system, it has come to the point to think about securing peoples passwords. How ever, for admin reasons I was wondering if it was possible to decode the encoded password, I believe this is not possible with md5 but hoping there is another method?
Any help would be geat, also any other information regarding safety, thanks.
Any help would be geat, also any other information regarding safety, thanks.
•
•
Join Date: May 2006
Location: New Jersey
Posts: 1,422
Reputation:
Rep Power: 5
Solved Threads: 34
Here is a good PHP5 class that uses the mcrypt library for two way encryption.
php Syntax (Toggle Plain Text)
<?php class Encryption { static $cypher = 'blowfish'; static $mode = 'cfb'; static $key = '1a2s3d4f5g6h'; public function encrypt($plaintext) { $td = mcrypt_module_open(self::$cypher, '', self::$mode, ''); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); mcrypt_generic_init($td, self::$key, $iv); $crypttext = mcrypt_generic($td, $plaintext); mcrypt_generic_deinit($td); return $iv.$crypttext; } public function decrypt($crypttext) { $plaintext = ""; $td = mcrypt_module_open(self::$cypher, '', self::$mode, ''); $ivsize = mcrypt_enc_get_iv_size($td); $iv = substr($crypttext, 0, $ivsize); $crypttext = substr($crypttext, $ivsize); if ($iv) { mcrypt_generic_init($td, self::$key, $iv); $plaintext = mdecrypt_generic($td, $crypttext); } return $plaintext; } } // Encrypt text $encrypted_text = Encryption::encrypt('this text is unencrypted'); // Decrypt text $decrypted_text = Encryption::decrypt($encrypted_text); ?>
Last edited by stymiee : Oct 15th, 2007 at 11:48 am.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
•
•
Join Date: May 2006
Location: New Jersey
Posts: 1,422
Reputation:
Rep Power: 5
Solved Threads: 34
It can be changed to work with PHP 4. You just need to change the PHP 5 features to 4:
php Syntax (Toggle Plain Text)
<?php class Encryption { var $cypher = 'blowfish'; var $mode = 'cfb'; var $key = '1a2s3d4f5g6h'; function Encryption() { // do nothing } function encrypt($plaintext) { $td = mcrypt_module_open($this->cypher, '', $this->mode, ''); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); mcrypt_generic_init($td, $this->key, $iv); $crypttext = mcrypt_generic($td, $plaintext); mcrypt_generic_deinit($td); return $iv.$crypttext; } function decrypt($crypttext) { $plaintext = ""; $td = mcrypt_module_open($this->cypher, '', $this->mode, ''); $ivsize = mcrypt_enc_get_iv_size($td); $iv = substr($crypttext, 0, $ivsize); $crypttext = substr($crypttext, $ivsize); if ($iv) { mcrypt_generic_init($td, $this->key, $iv); $plaintext = mdecrypt_generic($td, $crypttext); } return $plaintext; } } ?>
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Qestion on Encoding and Decoding. (Python)
- Slow computer + about:blank homepage (Viruses, Spyware and other Nasties)
- Encoding/Decoding (C)
- homepage hijack "Search for..." about:blank in address (Viruses, Spyware and other Nasties)
- Trojan Problem (Viruses, Spyware and other Nasties)
- Hijacked Repeatedly "about:blank" - Please Help (Viruses, Spyware and other Nasties)
- Need review of HJT log (Viruses, Spyware and other Nasties)
- Browser Hijack (about:blank) (Viruses, Spyware and other Nasties)
- my HJT log, 2 of them for 2 comp (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: how to call Stored Procedure in mysql by php
- Next Thread: limit text area words



Linear Mode