Jump to content

md5 or sha-1?


rockinaway

Recommended Posts

Here's a quick example of some minor flexibility that makes it hard even with a known algo

 

<?php

// Stored outside webroot

$usersalt = 'sha256';
$userhash = 'haval256,5';
$salt_size = 32;
$offset = 22;
$pass = 'i love you';

// Proof of concept. Don't use code below

$salt = hash( $usersalt, uniqid(mt_rand(), true) );
$saltlen = strlen($salt);
if ( $salt_size <= 16 || $salt_size > $saltlen )
  $salt_size = $saltlen;
else
  $salt = substr( $salt, mt_rand(0, $saltlen - $salt_size), $saltlen );
unset($saltlen);

$newpass = hash($userhash, $salt.$pass);

$hashed = substr( $salt, $offset-$salt_size ) . $newpass . substr($salt, 0, $offset);

echo $hashed;
echo '<br>';
echo $salt;
echo '<br>';
echo strlen($hashed) * 4 . ' bits';
  

?>

Link to comment
Share on other sites

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.