Blogvaria

This page is brought to you by Blogvaria (http://blog.evaria.com).

To obtain more information, ask questions and interact please visit our website.

Back to Blogvaria landing page
Feedback
Subscribe
   
Blogvaria

 

The personal pages

New hash functions in PHP

TrackBack | Filed by Thomas under Programming | Post popularity 6%

Safe and secure storage of passwords and other sensitive information is of great concern to every developer. Today I came across some new hash functions built in to the latest release of PHP.

To view the various algorithms you have available on your server add the following to a php page:

print_r(hash_algos());

To add the selected algorithm to your password or text do the following:

// sha512 is supposed to be unbreakable
$ctx = hash_init('sha512');
// apply the algorithm
hash_update($ctx, 'part_of_password');
// add more if you need
hash_update($ctx, 'continued_password');
// view result
echo hash_final($ctx);

This could come in handy when you need to encrypt your passwords stored in your database etc.

If you don’t get anything printed it’s due to the fact that your server isn’t running the latest version of PHP, this can’t be solved until either you or your host desides to upgrade…

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • BlinkList
  • blogmarks
  • del.icio.us
  • De.lirio.us
  • digg
  • Furl
  • NewsVine
  • Netscape
  • Reddit
  • Spurl
  • SphereIt
  • Technorati
  • YahooMyWeb
  • DZone
  • feedmelinks
  • Linkter
  • Ma.gnolia
  • Slashdot
  • StumbleUpon
  • TailRank
  • co.mments

No comments yet.

Leave a Comment

Akismet has protected Blogvaria from 68,541 spam comments. Design by Evaria.com. Powered by WordPress.
Our beloved and trusted server has rendered 2.211 pages so far today, an amazing 3.891 pages yesterday
and even more astonishingly 105.347 pages since 13 August 2008 alone without dropping a byte nor a pixel.

Close
E-mail It