generate-examples.pl 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861
  1. #!/usr/bin/perl
  2. ##
  3. ## Author......: Jens Steube <jens.steube@gmail.com>
  4. ## License.....: MIT
  5. ##
  6. use strict;
  7. use warnings;
  8. use Digest::MD5 qw (md5_hex);
  9. use Digest::SHA1 qw (sha1_hex);
  10. use MIME::Base64;
  11. my $tmp_hash = "hash";
  12. my $tmp_word = "word";
  13. my $tmp_out = "out";
  14. #my $hashcat = "./hashcat-cli.bin";
  15. my $hashcat = "hashcat-cli.exe";
  16. my $runs_per_test = 1;
  17. my $num_words_min = 100;
  18. my $num_words_max = 104;
  19. my $word_len_min = 1;
  20. my $word_len_max = 55;
  21. my $word_chr_min = 0x20;
  22. my $word_chr_max = 0x7e;
  23. my $salt_len_min = 1;
  24. my $salt_len_max = 54;
  25. test14 ();
  26. exit;
  27. sub simple_generate
  28. {
  29. for (1..$runs_per_test)
  30. {
  31. my $num_words = get_random_num ($num_words_min, $num_words_max);
  32. my %dupe;
  33. my $left = 10;
  34. while ($left)
  35. {
  36. ##
  37. ## word
  38. ##
  39. my $word_len = get_random_num ($word_len_min, 16);
  40. my @word_arr;
  41. for (my $i = 0; $i < $word_len; $i++)
  42. {
  43. push (@word_arr, get_random_chr (0x61, 0x7a));
  44. }
  45. my $word_buf = join ("", @word_arr);
  46. ##
  47. ## dupe
  48. ##
  49. next if exists $dupe{$word_buf};
  50. $dupe{$word_buf} = undef;
  51. ##
  52. ## store
  53. ##
  54. print $word_buf, "\n";
  55. $left--;
  56. }
  57. }
  58. }
  59. sub test24
  60. {
  61. my $test_num = 24;
  62. my $tmp_word = "examples/A0.M300.word";
  63. my $tmp_hash = "examples/A0.M300.hash";
  64. for (1..$runs_per_test)
  65. {
  66. my $num_words = get_random_num ($num_words_min, $num_words_max);
  67. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  68. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  69. my %dupe;
  70. my $left = $num_words;
  71. while ($left)
  72. {
  73. ##
  74. ## word
  75. ##
  76. my $word_len = get_random_num ($word_len_min, $word_len_max);
  77. my @word_arr;
  78. for (my $i = 0; $i < $word_len; $i++)
  79. {
  80. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  81. }
  82. my $word_buf = join ("", @word_arr);
  83. ##
  84. ## dupe
  85. ##
  86. next if exists $dupe{$word_buf};
  87. $dupe{$word_buf} = undef;
  88. ##
  89. ## store
  90. ##
  91. print OUTP $word_buf, "\n";
  92. my $ctx = Digest::SHA1->new;
  93. $ctx->add ($word_buf);
  94. my $hash_buf = sha1_hex ($ctx->digest);
  95. print OUTH $hash_buf, "\n";
  96. $left--;
  97. }
  98. close (OUTH);
  99. close (OUTP);
  100. unlink ($tmp_out);
  101. }
  102. }
  103. sub test23
  104. {
  105. my $test_num = 23;
  106. my $tmp_word = "examples/A0.M700.word";
  107. my $tmp_hash = "examples/A0.M700.hash";
  108. for (1..$runs_per_test)
  109. {
  110. my $num_words = get_random_num ($num_words_min, $num_words_max);
  111. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  112. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  113. my %dupe;
  114. my $left = $num_words;
  115. while ($left)
  116. {
  117. ##
  118. ## salt
  119. ##
  120. my $salt_len = 8;
  121. my @salt_arr;
  122. for (my $i = 0; $i < $salt_len; $i++)
  123. {
  124. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  125. }
  126. my $salt_buf = join ("", @salt_arr);
  127. ##
  128. ## word
  129. ##
  130. my $word_len = get_random_num ($word_len_min, $word_len_max - 8);
  131. my @word_arr;
  132. for (my $i = 0; $i < $word_len; $i++)
  133. {
  134. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  135. }
  136. my $word_buf = join ("", @word_arr);
  137. ##
  138. ## dupe
  139. ##
  140. next if exists $dupe{$word_buf};
  141. $dupe{$word_buf} = undef;
  142. ##
  143. ## store
  144. ##
  145. print OUTP $word_buf, "\n";
  146. my $ctx = Digest::SHA1->new;
  147. $ctx->add ($word_buf);
  148. $ctx->add ($salt_buf);
  149. my $hash_buf = "{SSHA}" . encode_base64 ($ctx->digest . $salt_buf);
  150. print OUTH $hash_buf;
  151. $left--;
  152. }
  153. close (OUTH);
  154. close (OUTP);
  155. unlink ($tmp_out);
  156. }
  157. }
  158. sub test22
  159. {
  160. my $test_num = 22;
  161. my $tmp_word = "examples/A0.M600.word";
  162. my $tmp_hash = "examples/A0.M600.hash";
  163. for (1..$runs_per_test)
  164. {
  165. my $num_words = get_random_num ($num_words_min, $num_words_max);
  166. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  167. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  168. my %dupe;
  169. my $left = $num_words;
  170. while ($left)
  171. {
  172. ##
  173. ## word
  174. ##
  175. my $word_len = get_random_num ($word_len_min, $word_len_max);
  176. my @word_arr;
  177. for (my $i = 0; $i < $word_len; $i++)
  178. {
  179. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  180. }
  181. my $word_buf = join ("", @word_arr);
  182. ##
  183. ## dupe
  184. ##
  185. next if exists $dupe{$word_buf};
  186. $dupe{$word_buf} = undef;
  187. ##
  188. ## store
  189. ##
  190. print OUTP $word_buf, "\n";
  191. my $ctx = Digest::SHA1->new;
  192. $ctx->add ($word_buf);
  193. my $hash_buf = "{SHA}" . encode_base64 ($ctx->digest);
  194. print OUTH $hash_buf;
  195. $left--;
  196. }
  197. close (OUTH);
  198. close (OUTP);
  199. unlink ($tmp_out);
  200. }
  201. }
  202. sub test21
  203. {
  204. my $test_num = 21;
  205. my $tmp_word = "examples/A0.M5.VBULLSALT.word";
  206. my $tmp_hash = "examples/A0.M5.VBULLSALT.hash";
  207. for (1..$runs_per_test)
  208. {
  209. my $num_words = get_random_num ($num_words_min, $num_words_max);
  210. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  211. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  212. my %dupe;
  213. my $left = $num_words;
  214. while ($left)
  215. {
  216. ##
  217. ## salt
  218. ##
  219. my $salt_len = get_random_num (3, 3);
  220. my @salt_arr;
  221. for (my $i = 0; $i < $salt_len; $i++)
  222. {
  223. push (@salt_arr, get_random_chr (0x20, 0x7e));
  224. }
  225. my $salt_buf = join ("", @salt_arr);
  226. ##
  227. ## word
  228. ##
  229. my $word_len = get_random_num ($word_len_min, 30);
  230. my @word_arr;
  231. for (my $i = 0; $i < $word_len; $i++)
  232. {
  233. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  234. }
  235. my $word_buf = join ("", @word_arr);
  236. ##
  237. ## dupe
  238. ##
  239. next if exists $dupe{$word_buf};
  240. $dupe{$word_buf} = undef;
  241. ##
  242. ## store
  243. ##
  244. print OUTP $word_buf, "\n";
  245. my $hash_buf = md5_hex (md5_hex ($word_buf) . $salt_buf);
  246. print OUTH $hash_buf, "\n";
  247. $left--;
  248. }
  249. close (OUTH);
  250. close (OUTP);
  251. unlink ($tmp_out);
  252. }
  253. }
  254. sub test20
  255. {
  256. my $test_num = 20;
  257. my $tmp_word = "examples/A0.M104.word";
  258. my $tmp_hash = "examples/A0.M104.hash";
  259. for (1..$runs_per_test)
  260. {
  261. my $num_words = get_random_num ($num_words_min, $num_words_max);
  262. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  263. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  264. my %dupe;
  265. my $left = $num_words;
  266. while ($left)
  267. {
  268. ##
  269. ## word
  270. ##
  271. my $word_len = get_random_num ($word_len_min, $word_len_max);
  272. my @word_arr;
  273. for (my $i = 0; $i < $word_len; $i++)
  274. {
  275. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  276. }
  277. my $word_buf = join ("", @word_arr);
  278. ##
  279. ## dupe
  280. ##
  281. next if exists $dupe{$word_buf};
  282. $dupe{$word_buf} = undef;
  283. ##
  284. ## store
  285. ##
  286. print OUTP $word_buf, "\n";
  287. my $hash_buf = sha1_hex (sha1_hex (sha1_hex ($word_buf)));
  288. print OUTH $hash_buf, "\n";
  289. $left--;
  290. }
  291. close (OUTH);
  292. close (OUTP);
  293. }
  294. }
  295. sub test19
  296. {
  297. my $test_num = 19;
  298. my $tmp_word = "examples/A0.M103.word";
  299. my $tmp_hash = "examples/A0.M103.hash";
  300. for (1..$runs_per_test)
  301. {
  302. my $num_words = get_random_num ($num_words_min, $num_words_max);
  303. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  304. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  305. my %dupe;
  306. my $left = $num_words;
  307. while ($left)
  308. {
  309. ##
  310. ## word
  311. ##
  312. my $word_len = get_random_num ($word_len_min, $word_len_max);
  313. my @word_arr;
  314. for (my $i = 0; $i < $word_len; $i++)
  315. {
  316. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  317. }
  318. my $word_buf = join ("", @word_arr);
  319. ##
  320. ## dupe
  321. ##
  322. next if exists $dupe{$word_buf};
  323. $dupe{$word_buf} = undef;
  324. ##
  325. ## store
  326. ##
  327. print OUTP $word_buf, "\n";
  328. my $hash_buf = sha1_hex (sha1_hex ($word_buf));
  329. print OUTH $hash_buf, "\n";
  330. $left--;
  331. }
  332. close (OUTH);
  333. close (OUTP);
  334. }
  335. }
  336. sub test18
  337. {
  338. my $test_num = 18;
  339. my $tmp_word = "examples/A3.M0.word";
  340. my $tmp_hash = "examples/A3.M0.hash";
  341. for (1..$runs_per_test)
  342. {
  343. my $num_words = get_random_num ($num_words_min, $num_words_max);
  344. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  345. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  346. my %dupe;
  347. my $left = $num_words;
  348. while ($left)
  349. {
  350. ##
  351. ## word
  352. ##
  353. my $word_len = 5;
  354. my @word_arr;
  355. for (my $i = 0; $i < $word_len; $i++)
  356. {
  357. push (@word_arr, get_random_chr (0x61, 0x7a));
  358. }
  359. my $word_buf = join ("", @word_arr);
  360. ##
  361. ## dupe
  362. ##
  363. next if exists $dupe{$word_buf};
  364. $dupe{$word_buf} = undef;
  365. ##
  366. ## store
  367. ##
  368. print OUTP $word_buf, "\n";
  369. my $hash_buf = md5_hex ($word_buf);
  370. print OUTH $hash_buf, "\n";
  371. $left--;
  372. }
  373. close (OUTH);
  374. close (OUTP);
  375. }
  376. }
  377. sub test16
  378. {
  379. my $test_num = 16;
  380. my $tmp_word = "examples/A0.M11.word";
  381. my $tmp_hash = "examples/A0.M11.hash";
  382. for (1..$runs_per_test)
  383. {
  384. my $num_words = get_random_num ($num_words_min, $num_words_max);
  385. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  386. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  387. my %dupe;
  388. my $left = $num_words;
  389. while ($left)
  390. {
  391. ##
  392. ## salt
  393. ##
  394. my $salt_len = get_random_num (1, 10);
  395. my @salt_arr;
  396. for (my $i = 0; $i < $salt_len; $i++)
  397. {
  398. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  399. }
  400. my $salt_buf = join ("", @salt_arr);
  401. ##
  402. ## word
  403. ##
  404. my $word_len = 10;
  405. my @word_arr;
  406. for (my $i = 0; $i < $word_len; $i++)
  407. {
  408. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  409. }
  410. my $word_buf = join ("", @word_arr);
  411. ##
  412. ## dupe
  413. ##
  414. next if exists $dupe{$word_buf};
  415. $dupe{$word_buf} = undef;
  416. ##
  417. ## store
  418. ##
  419. print OUTP $word_buf, "\n";
  420. my $hash_buf = md5_hex ($salt_buf . md5_hex ($salt_buf . $word_buf));
  421. print OUTH $hash_buf, ":", $salt_buf, "\n";
  422. $left--;
  423. }
  424. close (OUTH);
  425. close (OUTP);
  426. }
  427. }
  428. sub test17
  429. {
  430. my $test_num = 17;
  431. my $tmp_word = "examples/A0.M12.word";
  432. my $tmp_hash = "examples/A0.M12.hash";
  433. for (1..$runs_per_test)
  434. {
  435. my $num_words = get_random_num ($num_words_min, $num_words_max);
  436. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  437. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  438. my %dupe;
  439. my $left = $num_words;
  440. while ($left)
  441. {
  442. ##
  443. ## salt
  444. ##
  445. my $salt_len = 10;
  446. my @salt_arr;
  447. for (my $i = 0; $i < $salt_len; $i++)
  448. {
  449. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  450. }
  451. my $salt_buf = join ("", @salt_arr);
  452. ##
  453. ## word
  454. ##
  455. my $word_len = 10;
  456. my @word_arr;
  457. for (my $i = 0; $i < $word_len; $i++)
  458. {
  459. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  460. }
  461. my $word_buf = join ("", @word_arr);
  462. ##
  463. ## dupe
  464. ##
  465. next if exists $dupe{$word_buf};
  466. $dupe{$word_buf} = undef;
  467. ##
  468. ## store
  469. ##
  470. print OUTP $word_buf, "\n";
  471. my $hash_buf = md5_hex ($salt_buf . md5_hex ($word_buf . $salt_buf));
  472. print OUTH $hash_buf, ":", $salt_buf, "\n";
  473. $left--;
  474. }
  475. close (OUTH);
  476. close (OUTP);
  477. }
  478. }
  479. sub test13
  480. {
  481. my $test_num = 13;
  482. my $tmp_word = "examples/A0.M100.word";
  483. my $tmp_hash = "examples/A0.M100.hash";
  484. for (1..$runs_per_test)
  485. {
  486. my $num_words = get_random_num ($num_words_min, $num_words_max);
  487. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  488. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  489. my %dupe;
  490. my $left = $num_words;
  491. while ($left)
  492. {
  493. my $word_len = get_random_num ($word_len_min, $word_len_max);
  494. my @word_arr;
  495. for (my $i = 0; $i < $word_len; $i++)
  496. {
  497. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  498. }
  499. my $word_buf = join ("", @word_arr);
  500. next if exists $dupe{$word_buf};
  501. $dupe{$word_buf} = undef;
  502. print OUTP $word_buf, "\n";
  503. my $hash_buf = sha1_hex ($word_buf);
  504. print OUTH $hash_buf, "\n";
  505. $left--;
  506. }
  507. close (OUTH);
  508. close (OUTP);
  509. }
  510. }
  511. sub test14
  512. {
  513. my $test_num = 14;
  514. my $tmp_word = "examples/A0.M101.word";
  515. my $tmp_hash = "examples/A0.M101.hash";
  516. for (1..$runs_per_test)
  517. {
  518. my $num_words = get_random_num ($num_words_min, $num_words_max);
  519. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  520. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  521. my %dupe;
  522. my $left = $num_words;
  523. while ($left)
  524. {
  525. ##
  526. ## salt
  527. ##
  528. my $salt_len = get_random_num ($salt_len_min, $salt_len_max);
  529. my @salt_arr;
  530. for (my $i = 0; $i < $salt_len; $i++)
  531. {
  532. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  533. }
  534. my $salt_buf = join ("", @salt_arr);
  535. ##
  536. ## word
  537. ##
  538. my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
  539. my @word_arr;
  540. for (my $i = 0; $i < $word_len; $i++)
  541. {
  542. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  543. }
  544. my $word_buf = join ("", @word_arr);
  545. ##
  546. ## dupe
  547. ##
  548. next if exists $dupe{$word_buf};
  549. $dupe{$word_buf} = undef;
  550. ##
  551. ## store
  552. ##
  553. print OUTP $word_buf, "\n";
  554. my $hash_buf = sha1_hex ($word_buf . $salt_buf);
  555. print OUTH $hash_buf, ":", $salt_buf, "\n";
  556. $left--;
  557. }
  558. close (OUTH);
  559. close (OUTP);
  560. }
  561. }
  562. sub test15
  563. {
  564. my $test_num = 15;
  565. my $tmp_word = "examples/A0.M102.word";
  566. my $tmp_hash = "examples/A0.M102.hash";
  567. for (1..$runs_per_test)
  568. {
  569. my $num_words = get_random_num ($num_words_min, $num_words_max);
  570. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  571. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  572. my %dupe;
  573. my $left = $num_words;
  574. while ($left)
  575. {
  576. ##
  577. ## salt
  578. ##
  579. my $salt_len = get_random_num ($salt_len_min, $salt_len_max);
  580. my @salt_arr;
  581. for (my $i = 0; $i < $salt_len; $i++)
  582. {
  583. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  584. }
  585. my $salt_buf = join ("", @salt_arr);
  586. ##
  587. ## word
  588. ##
  589. my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
  590. my @word_arr;
  591. for (my $i = 0; $i < $word_len; $i++)
  592. {
  593. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  594. }
  595. my $word_buf = join ("", @word_arr);
  596. ##
  597. ## dupe
  598. ##
  599. next if exists $dupe{$word_buf};
  600. $dupe{$word_buf} = undef;
  601. ##
  602. ## store
  603. ##
  604. print OUTP $word_buf, "\n";
  605. my $hash_buf = sha1_hex ($salt_buf . $word_buf);
  606. print OUTH $hash_buf, ":", $salt_buf, "\n";
  607. $left--;
  608. }
  609. close (OUTH);
  610. close (OUTP);
  611. }
  612. }
  613. ##
  614. ## test1 : random number of passwords, random word length, random chars, 10 times
  615. ## : simple out -a 0 -m 0.
  616. ##
  617. sub test1
  618. {
  619. my $test_num = 1;
  620. my $tmp_word = "examples/A0.M0.word";
  621. my $tmp_hash = "examples/A0.M0.hash";
  622. for (1..$runs_per_test)
  623. {
  624. my $num_words = get_random_num ($num_words_min, $num_words_max);
  625. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  626. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  627. my %dupe;
  628. my $left = $num_words;
  629. while ($left)
  630. {
  631. my $word_len = get_random_num ($word_len_min, $word_len_max);
  632. my @word_arr;
  633. for (my $i = 0; $i < $word_len; $i++)
  634. {
  635. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  636. }
  637. my $word_buf = join ("", @word_arr);
  638. next if exists $dupe{$word_buf};
  639. $dupe{$word_buf} = undef;
  640. print OUTP $word_buf, "\n";
  641. my $hash_buf = md5_hex ($word_buf);
  642. print OUTH $hash_buf, "\n";
  643. $left--;
  644. }
  645. close (OUTH);
  646. close (OUTP);
  647. }
  648. }
  649. ##
  650. ## test2 : random number of passwords, random word length, random chars, 10 times
  651. ## : simple out -a 0 -m 1.
  652. ##
  653. sub test2
  654. {
  655. my $test_num = 2;
  656. my $tmp_word = "examples/A0.M1.word";
  657. my $tmp_hash = "examples/A0.M1.hash";
  658. for (1..$runs_per_test)
  659. {
  660. my $num_words = get_random_num ($num_words_min, $num_words_max);
  661. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  662. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  663. my %dupe;
  664. my $left = $num_words;
  665. while ($left)
  666. {
  667. ##
  668. ## salt
  669. ##
  670. my $salt_len = get_random_num ($salt_len_min, $salt_len_max);
  671. my @salt_arr;
  672. for (my $i = 0; $i < $salt_len; $i++)
  673. {
  674. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  675. }
  676. my $salt_buf = join ("", @salt_arr);
  677. ##
  678. ## word
  679. ##
  680. my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
  681. my @word_arr;
  682. for (my $i = 0; $i < $word_len; $i++)
  683. {
  684. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  685. }
  686. my $word_buf = join ("", @word_arr);
  687. ##
  688. ## dupe
  689. ##
  690. next if exists $dupe{$word_buf};
  691. $dupe{$word_buf} = undef;
  692. ##
  693. ## store
  694. ##
  695. print OUTP $word_buf, "\n";
  696. my $hash_buf = md5_hex ($word_buf . $salt_buf);
  697. print OUTH $hash_buf, ":", $salt_buf, "\n";
  698. $left--;
  699. }
  700. close (OUTH);
  701. close (OUTP);
  702. }
  703. }
  704. ##
  705. ## test3 : random number of passwords, random word length, random chars, 10 times
  706. ## : simple out -a 0 -m 2.
  707. ##
  708. sub test3
  709. {
  710. my $test_num = 3;
  711. my $tmp_word = "examples/A0.M2.word";
  712. my $tmp_hash = "examples/A0.M2.hash";
  713. for (1..$runs_per_test)
  714. {
  715. my $num_words = get_random_num ($num_words_min, $num_words_max);
  716. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  717. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  718. my %dupe;
  719. my $left = $num_words;
  720. while ($left)
  721. {
  722. ##
  723. ## salt
  724. ##
  725. my $salt_len = get_random_num ($salt_len_min, $salt_len_max);
  726. my @salt_arr;
  727. for (my $i = 0; $i < $salt_len; $i++)
  728. {
  729. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  730. }
  731. my $salt_buf = join ("", @salt_arr);
  732. ##
  733. ## word
  734. ##
  735. my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
  736. my @word_arr;
  737. for (my $i = 0; $i < $word_len; $i++)
  738. {
  739. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  740. }
  741. my $word_buf = join ("", @word_arr);
  742. ##
  743. ## dupe
  744. ##
  745. next if exists $dupe{$word_buf};
  746. $dupe{$word_buf} = undef;
  747. ##
  748. ## store
  749. ##
  750. print OUTP $word_buf, "\n";
  751. my $hash_buf = md5_hex ($salt_buf . $word_buf);
  752. print OUTH $hash_buf, ":", $salt_buf, "\n";
  753. $left--;
  754. }
  755. close (OUTH);
  756. close (OUTP);
  757. unlink ($tmp_out);
  758. }
  759. }
  760. ##
  761. ## test4 : random number of passwords, random word length, random chars, 10 times
  762. ## : simple out -a 0 -m 3.
  763. ##
  764. sub test4
  765. {
  766. my $test_num = 4;
  767. my $tmp_word = "examples/A0.M3.word";
  768. my $tmp_hash = "examples/A0.M3.hash";
  769. for (1..$runs_per_test)
  770. {
  771. my $num_words = get_random_num ($num_words_min, $num_words_max);
  772. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  773. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  774. my %dupe;
  775. my $left = $num_words;
  776. while ($left)
  777. {
  778. ##
  779. ## word
  780. ##
  781. my $word_len = get_random_num ($word_len_min, $word_len_max);
  782. my @word_arr;
  783. for (my $i = 0; $i < $word_len; $i++)
  784. {
  785. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  786. }
  787. my $word_buf = join ("", @word_arr);
  788. ##
  789. ## dupe
  790. ##
  791. next if exists $dupe{$word_buf};
  792. $dupe{$word_buf} = undef;
  793. ##
  794. ## store
  795. ##
  796. print OUTP $word_buf, "\n";
  797. my $hash_buf = md5_hex (md5_hex ($word_buf));
  798. print OUTH $hash_buf, "\n";
  799. $left--;
  800. }
  801. close (OUTH);
  802. close (OUTP);
  803. }
  804. }
  805. ##
  806. ## test5 : random number of passwords, random word length, random chars, 10 times
  807. ## : simple out -a 0 -m 4.
  808. ##
  809. sub test5
  810. {
  811. my $test_num = 5;
  812. my $tmp_word = "examples/A0.M4.word";
  813. my $tmp_hash = "examples/A0.M4.hash";
  814. for (1..$runs_per_test)
  815. {
  816. my $num_words = get_random_num ($num_words_min, $num_words_max);
  817. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  818. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  819. my %dupe;
  820. my $left = $num_words;
  821. while ($left)
  822. {
  823. ##
  824. ## word
  825. ##
  826. my $word_len = get_random_num ($word_len_min, $word_len_max);
  827. my @word_arr;
  828. for (my $i = 0; $i < $word_len; $i++)
  829. {
  830. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  831. }
  832. my $word_buf = join ("", @word_arr);
  833. ##
  834. ## dupe
  835. ##
  836. next if exists $dupe{$word_buf};
  837. $dupe{$word_buf} = undef;
  838. ##
  839. ## store
  840. ##
  841. print OUTP $word_buf, "\n";
  842. my $hash_buf = md5_hex (md5_hex (md5_hex ($word_buf)));
  843. print OUTH $hash_buf, "\n";
  844. $left--;
  845. }
  846. close (OUTH);
  847. close (OUTP);
  848. }
  849. }
  850. ##
  851. ## test6 : random number of passwords, random word length, random chars, 10 times
  852. ## : simple out -a 0 -m 5.
  853. ##
  854. sub test6
  855. {
  856. my $test_num = 6;
  857. my $tmp_word = "examples/A0.M5.word";
  858. my $tmp_hash = "examples/A0.M5.hash";
  859. for (1..$runs_per_test)
  860. {
  861. my $num_words = get_random_num ($num_words_min, $num_words_max);
  862. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  863. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  864. my %dupe;
  865. my $left = $num_words;
  866. while ($left)
  867. {
  868. ##
  869. ## salt
  870. ##
  871. my $salt_len = get_random_num (1, 10);
  872. my @salt_arr;
  873. for (my $i = 0; $i < $salt_len; $i++)
  874. {
  875. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  876. }
  877. my $salt_buf = join ("", @salt_arr);
  878. ##
  879. ## word
  880. ##
  881. my $word_len = get_random_num (1, 40);
  882. my @word_arr;
  883. for (my $i = 0; $i < $word_len; $i++)
  884. {
  885. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  886. }
  887. my $word_buf = join ("", @word_arr);
  888. ##
  889. ## dupe
  890. ##
  891. next if exists $dupe{$word_buf};
  892. $dupe{$word_buf} = undef;
  893. ##
  894. ## store
  895. ##
  896. print OUTP $word_buf, "\n";
  897. my $hash_buf = md5_hex (md5_hex ($word_buf) . $salt_buf);
  898. print OUTH $hash_buf, ":", $salt_buf, "\n";
  899. $left--;
  900. }
  901. close (OUTH);
  902. close (OUTP);
  903. }
  904. }
  905. ##
  906. ## test7 : random number of passwords, random word length, random chars, 10 times
  907. ## : simple out -a 0 -m 6.
  908. ##
  909. sub test7
  910. {
  911. my $test_num = 7;
  912. my $tmp_word = "examples/A0.M6.word";
  913. my $tmp_hash = "examples/A0.M6.hash";
  914. for (1..$runs_per_test)
  915. {
  916. my $num_words = get_random_num ($num_words_min, $num_words_max);
  917. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  918. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  919. my %dupe;
  920. my $left = $num_words;
  921. while ($left)
  922. {
  923. ##
  924. ## salt
  925. ##
  926. my $salt_len = 32;
  927. my @salt_arr;
  928. for (my $i = 0; $i < $salt_len; $i++)
  929. {
  930. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  931. }
  932. my $salt_buf = join ("", @salt_arr);
  933. ##
  934. ## word
  935. ##
  936. my $word_len = get_random_num ($word_len_min, $word_len_max - 32);
  937. my @word_arr;
  938. for (my $i = 0; $i < $word_len; $i++)
  939. {
  940. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  941. }
  942. my $word_buf = join ("", @word_arr);
  943. ##
  944. ## dupe
  945. ##
  946. next if exists $dupe{$word_buf};
  947. $dupe{$word_buf} = undef;
  948. ##
  949. ## store
  950. ##
  951. print OUTP $word_buf, "\n";
  952. my $hash_buf = md5_hex (md5_hex ($salt_buf) . $word_buf);
  953. print OUTH $hash_buf, ":", $salt_buf, "\n";
  954. $left--;
  955. }
  956. close (OUTH);
  957. close (OUTP);
  958. }
  959. }
  960. ##
  961. ## test8 : random number of passwords, random word length, random chars, 10 times
  962. ## : simple out -a 1.
  963. ##
  964. sub test8
  965. {
  966. my $test_num = 8;
  967. my $tmp_word = "examples/A1.M0.word";
  968. my $tmp_hash = "examples/A1.M0.hash";
  969. for (1..$runs_per_test)
  970. {
  971. my $num_words = get_random_num ($num_words_min, $num_words_max);
  972. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  973. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  974. my %dupe;
  975. my $left = $num_words;
  976. while ($left)
  977. {
  978. ##
  979. ## word
  980. ##
  981. my $word_len = get_random_num (6, 14);
  982. my @word_arr;
  983. for (my $i = 0; $i < $word_len; $i++)
  984. {
  985. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  986. }
  987. my $word_buf = join ("", @word_arr);
  988. my $word_buf_sep = int ($word_len / 2);
  989. my $word_buf_left = substr ($word_buf, 0, $word_buf_sep);
  990. my $word_buf_right = substr ($word_buf, $word_buf_sep);
  991. ##
  992. ## dupe
  993. ##
  994. next if exists $dupe{$word_buf};
  995. $dupe{$word_buf} = undef;
  996. ##
  997. ## store
  998. ##
  999. print OUTP $word_buf_left, "\n";
  1000. print OUTP $word_buf_right, "\n";
  1001. my $hash_buf = md5_hex ($word_buf);
  1002. print OUTH $hash_buf, "\n";
  1003. $left--;
  1004. }
  1005. close (OUTH);
  1006. close (OUTP);
  1007. }
  1008. }
  1009. ##
  1010. ## test9 : random number of passwords, random word length, random chars, 10 times
  1011. ## : simple out -a 0 -m 7.
  1012. ##
  1013. sub test9
  1014. {
  1015. my $test_num = 9;
  1016. my $tmp_word = "examples/A0.M7.word";
  1017. my $tmp_hash = "examples/A0.M7.hash";
  1018. for (1..$runs_per_test)
  1019. {
  1020. my $num_words = get_random_num ($num_words_min, $num_words_max);
  1021. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  1022. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  1023. my %dupe;
  1024. my $left = $num_words;
  1025. while ($left)
  1026. {
  1027. ##
  1028. ## salt
  1029. ##
  1030. my $salt_len = get_random_num ($salt_len_min, $salt_len_max - 32);
  1031. my @salt_arr;
  1032. for (my $i = 0; $i < $salt_len; $i++)
  1033. {
  1034. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1035. }
  1036. my $salt_buf = join ("", @salt_arr);
  1037. ##
  1038. ## word
  1039. ##
  1040. my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
  1041. my @word_arr;
  1042. for (my $i = 0; $i < $word_len; $i++)
  1043. {
  1044. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1045. }
  1046. my $word_buf = join ("", @word_arr);
  1047. ##
  1048. ## dupe
  1049. ##
  1050. next if exists $dupe{$word_buf};
  1051. $dupe{$word_buf} = undef;
  1052. ##
  1053. ## store
  1054. ##
  1055. print OUTP $word_buf, "\n";
  1056. my $hash_buf = md5_hex ($salt_buf . md5_hex ($word_buf));
  1057. print OUTH $hash_buf, ":", $salt_buf, "\n";
  1058. $left--;
  1059. }
  1060. close (OUTH);
  1061. close (OUTP);
  1062. }
  1063. }
  1064. ##
  1065. ## test10 : random number of passwords, random word length, random chars, 10 times
  1066. ## : simple out -a 0 -m 8.
  1067. ##
  1068. sub test10
  1069. {
  1070. my $test_num = 10;
  1071. my $tmp_word = "examples/A0.M8.word";
  1072. my $tmp_hash = "examples/A0.M8.hash";
  1073. for (1..$runs_per_test)
  1074. {
  1075. my $num_words = get_random_num ($num_words_min, $num_words_max);
  1076. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  1077. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  1078. my %dupe;
  1079. my $left = $num_words;
  1080. while ($left)
  1081. {
  1082. ##
  1083. ## salt
  1084. ##
  1085. my $salt_len = 10;
  1086. my @salt_arr;
  1087. for (my $i = 0; $i < $salt_len; $i++)
  1088. {
  1089. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1090. }
  1091. my $salt_buf = join ("", @salt_arr);
  1092. ##
  1093. ## word
  1094. ##
  1095. my $word_len = get_random_num ($word_len_min, $word_len_max - ($salt_len * 2));
  1096. my @word_arr;
  1097. for (my $i = 0; $i < $word_len; $i++)
  1098. {
  1099. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1100. }
  1101. my $word_buf = join ("", @word_arr);
  1102. ##
  1103. ## dupe
  1104. ##
  1105. next if exists $dupe{$word_buf};
  1106. $dupe{$word_buf} = undef;
  1107. ##
  1108. ## store
  1109. ##
  1110. print OUTP $word_buf, "\n";
  1111. my $hash_buf = md5_hex ($salt_buf . $word_buf . $salt_buf);
  1112. print OUTH $hash_buf, ":", $salt_buf, "\n";
  1113. $left--;
  1114. }
  1115. close (OUTH);
  1116. close (OUTP);
  1117. }
  1118. }
  1119. ##
  1120. ## test11 : random number of passwords, random word length, random chars, 10 times
  1121. ## : simple out -a 0 -m 9.
  1122. ##
  1123. sub test11
  1124. {
  1125. my $test_num = 11;
  1126. my $tmp_word = "examples/A0.M9.word";
  1127. my $tmp_hash = "examples/A0.M9.hash";
  1128. for (1..$runs_per_test)
  1129. {
  1130. my $num_words = get_random_num ($num_words_min, $num_words_max);
  1131. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  1132. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  1133. my %dupe;
  1134. my $left = $num_words;
  1135. while ($left)
  1136. {
  1137. ##
  1138. ## salt
  1139. ##
  1140. my $salt_len = 10;
  1141. my @salt_arr;
  1142. for (my $i = 0; $i < $salt_len; $i++)
  1143. {
  1144. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1145. }
  1146. my $salt_buf = join ("", @salt_arr);
  1147. ##
  1148. ## word
  1149. ##
  1150. my $word_len = 10;
  1151. my @word_arr;
  1152. for (my $i = 0; $i < $word_len; $i++)
  1153. {
  1154. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1155. }
  1156. my $word_buf = join ("", @word_arr);
  1157. ##
  1158. ## dupe
  1159. ##
  1160. next if exists $dupe{$word_buf};
  1161. $dupe{$word_buf} = undef;
  1162. ##
  1163. ## store
  1164. ##
  1165. print OUTP $word_buf, "\n";
  1166. my $hash_buf = md5_hex (md5_hex ($salt_buf) . md5_hex ($word_buf));
  1167. print OUTH $hash_buf, ":", $salt_buf, "\n";
  1168. $left--;
  1169. }
  1170. close (OUTH);
  1171. close (OUTP);
  1172. }
  1173. }
  1174. sub test12
  1175. {
  1176. my $test_num = 12;
  1177. my $tmp_word = "examples/A0.M10.word";
  1178. my $tmp_hash = "examples/A0.M10.hash";
  1179. for (1..$runs_per_test)
  1180. {
  1181. my $num_words = get_random_num ($num_words_min, $num_words_max);
  1182. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  1183. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  1184. my %dupe;
  1185. my $left = $num_words;
  1186. while ($left)
  1187. {
  1188. ##
  1189. ## salt
  1190. ##
  1191. my $salt_len = 10;
  1192. my @salt_arr;
  1193. for (my $i = 0; $i < $salt_len; $i++)
  1194. {
  1195. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1196. }
  1197. my $salt_buf = join ("", @salt_arr);
  1198. ##
  1199. ## word
  1200. ##
  1201. my $word_len = 10;
  1202. my @word_arr;
  1203. for (my $i = 0; $i < $word_len; $i++)
  1204. {
  1205. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1206. }
  1207. my $word_buf = join ("", @word_arr);
  1208. ##
  1209. ## dupe
  1210. ##
  1211. next if exists $dupe{$word_buf};
  1212. $dupe{$word_buf} = undef;
  1213. ##
  1214. ## store
  1215. ##
  1216. print OUTP $word_buf, "\n";
  1217. my $hash_buf = md5_hex (md5_hex ($word_buf) . md5_hex ($salt_buf));
  1218. print OUTH $hash_buf, ":", $salt_buf, "\n";
  1219. $left--;
  1220. }
  1221. close (OUTH);
  1222. close (OUTP);
  1223. }
  1224. }
  1225. ##
  1226. ## subs
  1227. ##
  1228. sub comword
  1229. {
  1230. my $test_num = shift;
  1231. my $msg = shift;
  1232. die ("$test_num: $msg\n");
  1233. }
  1234. sub get_lines_in_file
  1235. {
  1236. my $file = shift;
  1237. my $count = 0;
  1238. open (IN, $file) or die ("$file: $!\n");
  1239. while (<IN>) { $count++ }
  1240. close (IN);
  1241. return $count;
  1242. }
  1243. sub get_random_num
  1244. {
  1245. my $min = shift;
  1246. my $max = shift;
  1247. return int ((rand ($max - $min)) + $min);
  1248. }
  1249. sub get_random_chr
  1250. {
  1251. return chr get_random_num (@_);
  1252. }