Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. check.php:
  2.  
  3. <?php
  4. if(isset($_POST['randomString']) && isset($_POST['md5_string'])) {
  5.     $randomString = $_POST['randomString'];
  6.     $md5_string = $_POST['md5_string'];
  7.     if(md5($randomString) == $md5_string) {
  8.         echo "Strings Match";
  9.         } else {
  10.         echo "Something fucked up<br>";
  11.         echo "Received md5: " . md5($randomString) . "<br>";
  12.         echo "POST md5: " . $md5_string;
  13.        
  14.     }
  15. } else {
  16. echo "POST was improperly set.";
  17. }
  18. ?>
  19.  
  20.  
  21. index.php:
  22. <?php
  23.     $chars = '123456789abcdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPRSTUVWXYZ';
  24.     $randomString = '';
  25.     $linemin = 6;
  26.     $linemax = 8;
  27.     $lines = 4000;
  28.  
  29. for ($x = 0; $x < $lines; $x++) {
  30.     $randline = rand($linemin, $linemax);
  31.     for ($i = 0; $i < $randline; $i++)
  32.     {
  33.         $randomString .= $chars[rand(0, strlen($chars)-1)];
  34.     }
  35.     $randomString .= "\n";
  36. }
  37.  
  38. $md5_string = md5($randomString);
  39.  
  40. $size = mb_strlen($randomString, 'latin1');
  41. if($size >= 1024) {
  42.     $size = round($size / 1024, 2).' KB';
  43.     } else {
  44.     $size = $size.' bytes';
  45. }
  46. echo "Size of randomString: " . $size;
  47.  
  48. ?>
  49.  
  50. <form action='check.php' method='POST'>
  51. <textarea name='randomString' cols=20 rows=20><?php echo $randomString; ?></textarea><br>
  52. <input type='text' size='40' name='md5_string' value='<?php echo $md5_string; ?>'><br>
  53. <input type='submit' name='submit' value='submit'>
  54. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement