patchido Posted March 7, 2013 Share Posted March 7, 2013 I am trying to upload a big amount of users into a table in mysql, for this i want to import via phpmyadmin, the only problem is that the password is hasshed, so i did a php file for converting the bulk of passwords into sha1, i did a test with one of them and it is not the same value as if i created with another, can anyone tell why?? this is my code for the bulk. <?php if (isset($_POST['submit'])) { $textarea = $_POST['passwords']; $pass_array = explode("\n",$textarea); $sha1_array= array(); foreach($pass_array as $pass){ $sha1_array[] = sha1($pass); } echo print_r($sha1_array); } ?> <form action="pass.php" method="post"> <textarea name="passwords" cols="20" rows="1100"></textarea><br /> <input type="submit" name="submit" value="sha1" /> </form> Thanks Quote Link to comment https://forums.phpfreaks.com/topic/275373-hashing-passwords/ Share on other sites More sharing options...
patchido Posted March 7, 2013 Author Share Posted March 7, 2013 i figured out that this is caused on the \n after each line, how can i get rid of this? Quote Link to comment https://forums.phpfreaks.com/topic/275373-hashing-passwords/#findComment-1417240 Share on other sites More sharing options...
Solution Christian F. Posted March 7, 2013 Solution Share Posted March 7, 2013 trim. Quote Link to comment https://forums.phpfreaks.com/topic/275373-hashing-passwords/#findComment-1417257 Share on other sites More sharing options...
patchido Posted March 7, 2013 Author Share Posted March 7, 2013 thanks, i did figured out, but help is appreciated Quote Link to comment https://forums.phpfreaks.com/topic/275373-hashing-passwords/#findComment-1417260 Share on other sites More sharing options...
Psycho Posted March 7, 2013 Share Posted March 7, 2013 (edited) FYI: You can greatly reduce that code (and implement trim): $sha1_array = array_map('sha1', array_map('trim', explode("\n", $_POST['passwords']))); echo print_r($sha1_array); Edited March 7, 2013 by Psycho Quote Link to comment https://forums.phpfreaks.com/topic/275373-hashing-passwords/#findComment-1417290 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.