TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-11-2009, 07:09 PM   #1 (permalink)
The Contributor
 
tego10122's Avatar
 
Join Date: Sep 2008
Location: Miami
Posts: 39
Thanks: 7
tego10122 is on a distinguished road
Default Creating your own encryption method

Hello , How could I compile a class/function to create my own encryption method.

eg:
Code:
$text = 'milkdud22' 
output: my25Ql$jk
__________________
You're Everyday Graphic Artist
Twitter|GigPark|Linked In
Send a message via MSN to tego10122
tego10122 is offline  
Reply With Quote
Old 02-11-2009, 07:23 PM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Just scramble the input with some string functions like so:

php Code:
function TalkPHP_Encrypt($szString)
{
    $szString = str_rot13($szString);
    $szString = md5($szString);
    $szString = substr($szString, 5, 15);
    return $szString;
}

echo TalkPHP_Encrypt('Everybody at TalkPHP loves encryption');

That is of course unless you want to reverse it, in which case it'll require a little more thought. What is wrong with the in-built encryption methods, however?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 02-12-2009, 04:12 AM   #3 (permalink)
The Contributor
 
tego10122's Avatar
 
Join Date: Sep 2008
Location: Miami
Posts: 39
Thanks: 7
tego10122 is on a distinguished road
Default

Um , well nothing really I just like to have it so I have my own encryption method hopefully making it harder to crack.
__________________
You're Everyday Graphic Artist
Twitter|GigPark|Linked In
Send a message via MSN to tego10122
tego10122 is offline  
Reply With Quote
Old 02-12-2009, 04:23 AM   #4 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Anything you create will probably be worse than the major existing methods (SHA1 is still to be reverse engineered). The methods you have now are created by people who have real experience in this stuff. One of the first rules of using encryption methods is "Don't use your own".
__________________

Village Idiot is offline  
Reply With Quote
Old 02-12-2009, 01:35 PM   #5 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

As Village Idiot said, SHA1's yet to be reversed. Add a salt to that SHA1 and even dictionary attacks will be fruitless.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 02-12-2009, 06:03 PM   #6 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

The best idea is to use a combination of encryption methods. I personally use this:

PHP Code:
$newpass sha1(md5('password')); 
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 02-12-2009, 06:56 PM   #7 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by ETbyrne View Post
The best idea is to use a combination of encryption methods. I personally use this:

PHP Code:
$newpass sha1(md5('password')); 
Why would that be any better? If they get reverse engineered it would not be hard at all to get past that. Reason being that they both leave data in an easy to spot format. If you want to make it virtually impossible to reverse engineer (w/o seeing the script), combine the two strings and substring a few out. This will essentially take any possible footprint away and destroy the data. If they see your script, they would still have to cross-reference the two values that they see and try to triangulate the missing letters off of that.
__________________

Village Idiot is offline  
Reply With Quote
Old 02-12-2009, 07:07 PM   #8 (permalink)
The Acquainted
 
Join Date: Oct 2007
Posts: 170
Thanks: 18
maZtah is an unknown quantity at this point
Default

I'm using the method Wildhoney mentioned.

PHP Code:
define('SALT''SD9isd9034K#J$Ldfdf9I_DLKAMSD;l=');

$szPassword sha1(SALT $_POST['password']); 
Then for every website I'm setting another SALT.
maZtah is offline  
Reply With Quote
Old 02-12-2009, 07:12 PM   #9 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Quote:
Originally Posted by ETbyrne View Post
The best idea is to use a combination of encryption methods. I personally use this:

PHP Code:
$newpass sha1(md5('password')); 
That's the best piece of bad advice I've seen all day. Mixing multiple hashing algorithms does not a secure system make. Once an attacker knows that all you're feeding into SHA1 is an unsalted MD5 hash, their life just got way easier.
Salathe is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHPBB3 Password Encryption Orc General 4 01-17-2010 01:02 AM
PGP Encryption aristoworks General 0 12-03-2008 06:50 PM
Assigning non-static properties from a static method? delayedinsanity Advanced PHP Programming 4 07-10-2008 02:49 PM
Creating a PHP ACL and even Rat out Users using Proxies! Wildhoney General 0 09-22-2007 10:48 AM
Method to check Size of Remote File alex.zeal Tips & Tricks 4 09-22-2007 10:22 AM


All times are GMT. The time now is 09:13 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design