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 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? Link to comment https://forums.phpfreaks.com/topic/275373-hashing-passwords/#findComment-1417240 Share on other sites More sharing options...
Christian F. Posted March 7, 2013 Share Posted March 7, 2013 trim. 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 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 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); Link to comment https://forums.phpfreaks.com/topic/275373-hashing-passwords/#findComment-1417290 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.