variable _index [pid]; proc password {length} { global _index; variable _set {shW4UMe832TpaSylIdfzxbrNki9A7Q5PmZ0XDuYVg1KEGwLcJtjRCF6OqovBHn}; variable _password {}; for {set _char 1} {$_char <= $length} {incr _char} { incr _index [lindex [time { while {$_index >= [string length $_set]} { incr _index -[string length $_set]; } # Only usefull to increase entropy for {set _count $_index} {$_count <= [string length $_set]+[string index [clock microseconds] end]} {incr _count} { # Nothing to do } set _password $_password[string index $_set $_index]; }] 0] } return $_password; }Call password length inside the script.bll 2016-4-16: c.f. google groups discussionAMG: My first instinct was to optimize this code since it is written in a seemingly wasteful way. However, there is a trick, a method to the madness. The time command is used as a random number generator, used to advance the index into the character set. So inefficient programming with somewhat unpredictable runtime is exactly the programmer's intent.bll 2016-4-15:See [1]:The output from "ent" for 80000 characters, password 8 called 10000 times. The serial correlation coefficient is quite high.
Entropy = 4.787082 bits per byte. Optimum compression would reduce the size of this 80000 byte file by 40 percent. Chi square distribution for 80000 samples is 841393.86, and randomly would exceed this value 0.01 percent of the times. Arithmetic mean value of data bytes is 93.7709 (127.5 = random). Monte Carlo value for Pi is 4.000000000 (error 27.32 percent). Serial correlation coefficient is -0.204070 (totally uncorrelated = 0.0).
paskali 2016-04-15:Thanks. I am crazy.
paskali - 2016-04-16 13:38:58Update, now the previous test should be something like this (on a pII 366Mhz):
Value Char Occurrences Fraction 48 0 1346 0.016825 49 1 1254 0.015675 50 2 1289 0.016112 51 3 1279 0.015988 52 4 1280 0.016000 53 5 1298 0.016225 54 6 1184 0.014800 55 7 1333 0.016663 56 8 1332 0.016650 57 9 1241 0.015513 65 A 1262 0.015775 66 B 1322 0.016525 67 C 1259 0.015738 68 D 1318 0.016475 69 E 1224 0.015300 70 F 1268 0.015850 71 G 1335 0.016688 72 H 1249 0.015612 73 I 1294 0.016175 74 J 1285 0.016063 75 K 1323 0.016538 76 L 1296 0.016200 77 M 1292 0.016150 78 N 1261 0.015762 79 O 1223 0.015288 80 P 1310 0.016375 81 Q 1289 0.016112 82 R 1300 0.016250 83 S 1252 0.015650 84 T 1337 0.016713 85 U 1320 0.016500 86 V 1293 0.016162 87 W 1303 0.016287 88 X 1312 0.016400 89 Y 1310 0.016375 90 Z 1290 0.016125 97 a 1360 0.017000 98 b 1326 0.016575 99 c 1253 0.015662 100 d 1302 0.016275 101 e 1244 0.015550 102 f 1307 0.016338 103 g 1330 0.016625 104 h 1267 0.015838 105 i 1349 0.016862 106 j 1290 0.016125 107 k 1290 0.016125 108 l 1215 0.015187 109 m 1288 0.016100 110 n 1273 0.015912 111 o 1272 0.015900 112 p 1308 0.016350 113 q 1363 0.017038 114 r 1269 0.015863 115 s 1281 0.016012 116 t 1339 0.016737 117 u 1281 0.016012 118 v 1257 0.015713 119 w 1276 0.015950 120 x 1295 0.016188 121 y 1280 0.016000 122 z 1322 0.016525 Total: 80000 1.000000 Entropy = 5.953637 bits per byte. Optimum compression would reduce the size of this 80000 byte file by 25 percent. Chi square distribution for 80000 samples is 250577.73, and randomly would exceed this value less than 0.01 percent of the times. Arithmetic mean value of data bytes is 86.9505 (127.5 = random). Monte Carlo value for Pi is 4.000000000 (error 27.32 percent). Serial correlation coefficient is 0.000214 (totally uncorrelated = 0.0).
bll 2016-4-16The latest version:See [2]:The output from "ent" for 80000 characters, password 8 called 10000 times. The serial correlation coefficient is very high. As seen from the character occurrence table, this is not a strong generator.
Entropy = 3.753542 bits per byte. Optimum compression would reduce the size of this 80000 byte file by 53 percent. Chi square distribution for 80000 samples is 1668541.12, and randomly would exceed this value 0.01 percent of the times. Arithmetic mean value of data bytes is 101.3792 (127.5 = random). Monte Carlo value for Pi is 4.000000000 (error 27.32 percent). Serial correlation coefficient is -0.048597 (totally uncorrelated = 0.0).The character occurence table:
Value Char Occurrences Fraction 48 0 64 0.000800 49 1 31 0.000387 50 2 12 0.000150 51 3 17 0.000212 52 4 11 0.000138 53 5 122 0.001525 54 6 11 0.000138 55 7 183 0.002288 56 8 18 0.000225 57 9 1063 0.013288 65 A 277 0.003462 66 B 12 0.000150 67 C 17 0.000212 68 D 64 0.000800 69 E 25 0.000313 70 F 17 0.000212 71 G 15 0.000188 72 H 10 0.000125 73 I 6791 0.084888 74 J 13 0.000162 75 K 24 0.000300 76 L 17 0.000212 77 M 11 0.000138 78 N 7556 0.094450 79 O 14 0.000175 80 P 111 0.001388 81 Q 152 0.001900 82 R 7 0.000087 83 S 309 0.003863 84 T 17 0.000212 85 U 10 0.000125 86 V 41 0.000513 87 W 12 0.000150 88 X 62 0.000775 89 Y 52 0.000650 90 Z 98 0.001225 97 a 120 0.001500 98 b 7842 0.098025 99 c 13 0.000162 100 d 7534 0.094175 101 e 15 0.000188 102 f 7720 0.096500 103 g 21 0.000262 104 h 15 0.000188 105 i 3328 0.041600 106 j 21 0.000262 107 k 7020 0.087750 108 l 4747 0.059338 109 m 102 0.001275 110 n 8 0.000100 111 o 13 0.000162 112 p 15 0.000188 113 q 11 0.000138 114 r 7738 0.096725 115 s 15 0.000188 116 t 20 0.000250 117 u 46 0.000575 118 v 12 0.000150 119 w 19 0.000237 120 x 7718 0.096475 121 y 817 0.010212 122 z 7804 0.097550 Total: 80000 1.000000
See Also edit
paskali - 2016-04-16 16:43:09On the mine (AMD E-450 processor 1650Mhz):
Value Char Occurrences Fraction 48 0 1344 0.016800 49 1 1192 0.014900 50 2 1318 0.016475 51 3 1414 0.017675 52 4 1251 0.015637 53 5 1213 0.015163 54 6 1324 0.016550 55 7 1406 0.017575 56 8 1354 0.016925 57 9 1432 0.017900 65 A 1455 0.018187 66 B 1222 0.015275 67 C 1225 0.015313 68 D 1454 0.018175 69 E 1289 0.016112 70 F 1261 0.015762 71 G 1299 0.016237 72 H 1347 0.016837 73 I 1300 0.016250 74 J 1241 0.015513 75 K 1218 0.015225 76 L 1310 0.016375 77 M 1223 0.015288 78 N 1250 0.015625 79 O 1324 0.016550 80 P 1214 0.015175 81 Q 1284 0.016050 82 R 1144 0.014300 83 S 1132 0.014150 84 T 1333 0.016663 85 U 1211 0.015138 86 V 1226 0.015325 87 W 1399 0.017488 88 X 1396 0.017450 89 Y 1291 0.016137 90 Z 1205 0.015063 97 a 1287 0.016088 98 b 1252 0.015650 99 c 1312 0.016400 100 d 1367 0.017087 101 e 1244 0.015550 102 f 1508 0.018850 103 g 1149 0.014363 104 h 1345 0.016813 105 i 1344 0.016800 106 j 1250 0.015625 107 k 1206 0.015075 108 l 1270 0.015875 109 m 1211 0.015138 110 n 1306 0.016325 111 o 1241 0.015513 112 p 1279 0.015988 113 q 1309 0.016362 114 r 1200 0.015000 115 s 1361 0.017013 116 t 1194 0.014925 117 u 1410 0.017625 118 v 1166 0.014575 119 w 1385 0.017313 120 x 1321 0.016512 121 y 1176 0.014700 122 z 1406 0.017575 Total: 80000 1.000000 Entropy = 5.951122 bits per byte. Optimum compression would reduce the size of this 80000 byte file by 25 percent. Chi square distribution for 80000 samples is 251738.34, and randomly would exceed this value less than 0.01 percent of the times. Arithmetic mean value of data bytes is 86.7243 (127.5 = random). Monte Carlo value for Pi is 4.000000000 (error 27.32 percent). Serial correlation coefficient is -0.001069 (totally uncorrelated = 0.0).
paskali - 2016-04-16 17:48:26On WM8880 dual core cortex A9 (someting like an ARM)
Value Char Occurrences Fraction 48 0 1298 0.016225 49 1 1326 0.016575 50 2 1338 0.016725 51 3 1311 0.016387 52 4 1278 0.015975 53 5 1231 0.015388 54 6 1307 0.016338 55 7 1271 0.015887 56 8 1274 0.015925 57 9 1343 0.016788 65 A 1293 0.016162 66 B 1298 0.016225 67 C 1311 0.016387 68 D 1260 0.015750 69 E 1258 0.015725 70 F 1294 0.016175 71 G 1296 0.016200 72 H 1292 0.016150 73 I 1288 0.016100 74 J 1360 0.017000 75 K 1289 0.016112 76 L 1293 0.016162 77 M 1307 0.016338 78 N 1312 0.016400 79 O 1346 0.016825 80 P 1280 0.016000 81 Q 1314 0.016425 82 R 1352 0.016900 83 S 1324 0.016550 84 T 1338 0.016725 85 U 1284 0.016050 86 V 1341 0.016762 87 W 1247 0.015588 88 X 1368 0.017100 89 Y 1342 0.016775 90 Z 1324 0.016550 97 a 1297 0.016213 98 b 1234 0.015425 99 c 1284 0.016050 100 d 1245 0.015562 101 e 1298 0.016225 102 f 1281 0.016012 103 g 1302 0.016275 104 h 1241 0.015513 105 i 1222 0.015275 106 j 1241 0.015513 107 k 1309 0.016362 108 l 1285 0.016063 109 m 1270 0.015875 110 n 1333 0.016663 111 o 1248 0.015600 112 p 1287 0.016088 113 q 1228 0.015350 114 r 1295 0.016188 115 s 1223 0.015288 116 t 1285 0.016063 117 u 1310 0.016375 118 v 1296 0.016200 119 w 1252 0.015650 120 x 1227 0.015338 121 y 1240 0.015500 122 z 1279 0.015988 Total: 80000 1.000000 Entropy = 5.953627 bits per byte. Optimum compression would reduce the size of this 80000 byte file by 25 percent. Chi square distribution for 80000 samples is 250583.02, and randomly would exceed this value less than 0.01 percent of the times. Arithmetic mean value of data bytes is 86.6740 (127.5 = random). Monte Carlo value for Pi is 4.000000000 (error 27.32 percent). Serial correlation coefficient is 0.003713 (totally uncorrelated = 0.0).