RobertP Posted December 30, 2011 Share Posted December 30, 2011 any visible issues ? private function encrypt($string,$salt){ return utf8_encode(hash('sha256',substr($salt,(int)(floor(strlen($salt)/2))).$string.substr($salt,0,(int)((floor(strlen($salt)/2))*-1)))); } edit: example $string = 'password'; $salt = '12345678'; the script will encrypt the password as $string = '1234password5678'; Quote Link to comment https://forums.phpfreaks.com/topic/254096-encrypt-stringsalt/ Share on other sites More sharing options...
requinix Posted December 31, 2011 Share Posted December 31, 2011 1. That's hashing, not encryption. 2. Actually it would hash "1234password1234". Remove the ",0" in the second call to substr() to fix that. Quote Link to comment https://forums.phpfreaks.com/topic/254096-encrypt-stringsalt/#findComment-1302724 Share on other sites More sharing options...
scootstah Posted January 1, 2012 Share Posted January 1, 2012 Why make the salt only numbers? It would be more secure with 0-9a-zA-Z. hash_hmac() is better too. Quote Link to comment https://forums.phpfreaks.com/topic/254096-encrypt-stringsalt/#findComment-1303069 Share on other sites More sharing options...
RobertP Posted January 3, 2012 Author Share Posted January 3, 2012 that is just an example Quote Link to comment https://forums.phpfreaks.com/topic/254096-encrypt-stringsalt/#findComment-1303581 Share on other sites More sharing options...
scootstah Posted January 3, 2012 Share Posted January 3, 2012 Right, my bad. By the way, splitting the salt like that really doesn't accomplish anything. It is no more secure than standard salting. Security through obscurity isn't security. Quote Link to comment https://forums.phpfreaks.com/topic/254096-encrypt-stringsalt/#findComment-1303591 Share on other sites More sharing options...
PFMaBiSmAd Posted January 3, 2012 Share Posted January 3, 2012 utf8_encode is not needed because all the characters are plain ASCII characters - the characters 0-9a-f. Quote Link to comment https://forums.phpfreaks.com/topic/254096-encrypt-stringsalt/#findComment-1303686 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.