Last active
February 12, 2017 22:06
-
-
Save daif/c226f057ba02da715223a7f31a96b6df to your computer and use it in GitHub Desktop.
search in text file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// script startup time and memory usage | |
$mem_usage = memory_get_usage(); | |
$time_usage = microtime(true); | |
$return = 'FALSE'; | |
$password = '070162'; | |
// get password list file from https://github.com/danielmiessler/SecLists/tree/master/Passwords | |
/* don't touch the above lines */ | |
/* ------------------------------------------------------------------- */ | |
// open file in reading mode | |
$fp = fopen('10_million_password_list_top_100000.txt', 'r'); | |
// read file line by line | |
while (($buffer = fgets($fp)) !== false) { | |
// compare password with read line , and break the loop if yes | |
if(trim($buffer) == $password) { | |
$return = 'TRUE'; | |
break; | |
} | |
} | |
//close file | |
fclose($fp); | |
/* ------------------------------------------------------------------- */ | |
/* don't touch the below lines */ | |
echo 'Return: '.$return."<br />\n"; | |
// calculate script time and memory usage | |
$mem_usage = ((memory_get_usage() - $mem_usage)); | |
$time_usage = (microtime(true) - $time_usage); | |
if($mem_usage<1024) { | |
$mem_usage .= ' bytes'; | |
}elseif($mem_usage<1048576) { | |
$mem_usage = number_format(($mem_usage/1024), 3, '.', '').' kilobytes'; | |
} else { | |
$mem_usage = number_format(($mem_usage/1048576), 3, '.', '').' megabytes'; | |
} | |
echo "----------------------<br />\n"; | |
echo 'Memory usage: '.$mem_usage." <br />\n"; | |
echo 'Time speed: '.number_format($time_usage, 3, '.', '')." sec<br />\n"; | |
echo "----------------------<br />\n"; | |
echo 'PHP: '.phpversion()." <br />\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment