Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. function generate_file($file_name, $size_in_bytes)
  2. {
  3. $data = str_repeat(rand(0,9), $size_in_bytes);
  4. file_put_contents($file_name, $data); //writes $data in a file
  5. }
  6.  
  7. fsutil file createnew d:filepathfilename.txt 1048576
  8.  
  9. dd if=/dev/zero of=filepath/filename.txt bs=10000000 count=1
  10.  
  11. function file_rand($filename, $filesize) {
  12. if ($h = fopen($filename, 'w')) {
  13. if ($filesize > 1024) {
  14. for ($i = 0; $i < floor($filesize / 1024); $i++) {
  15. fwrite($h, bin2hex(openssl_random_pseudo_bytes(511)) . PHP_EOL);
  16. }
  17. $filesize = $filesize - (1024 * $i);
  18. }
  19. $mod = $filesize % 2;
  20. fwrite($h, bin2hex(openssl_random_pseudo_bytes(($filesize - $mod) / 2)));
  21. if ($mod) {
  22. fwrite($h, substr(uniqid(), 0, 1));
  23. }
  24. fclose($h);
  25. umask(0000);
  26. chmod($filename, 0644);
  27. }
  28. }
  29.  
  30. $data = '';
  31. for ($byteSize-- >= 0) {
  32. $data .= chr(rand(0,255));
  33. }
  34.  
  35. function CreatFileDummy($file_name,$size = 90294967296 ) {
  36. // 32bits 4 294 967 296 bytes MAX Size
  37. $f = fopen('dummy/'.$file_name, 'wb');
  38. if($size >= 1000000000) {
  39. $z = ($size / 1000000000);
  40. if (is_float($z)) {
  41. $z = round($z,0);
  42. fseek($f, ( $size - ($z * 1000000000) -1 ), SEEK_END);
  43. fwrite($f, "");
  44. }
  45. while(--$z > -1) {
  46. fseek($f, 999999999, SEEK_END);
  47. fwrite($f, "");
  48. }
  49. }
  50. else {
  51. fseek($f, $size - 1, SEEK_END);
  52. fwrite($f, "");
  53. }
  54. fclose($f);
  55.  
  56. return true;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement