Browse code

initial import

devnewton authored on 22/03/2011 at 23:47:05
Showing 4 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,189 @@
0
+/* 
1
+ * More info at: http://phpjs.org
2
+ * 
3
+ * This is version: 3.23
4
+ * php.js is copyright 2011 Kevin van Zonneveld.
5
+ * 
6
+ * Portions copyright Brett Zamir (http://brett-zamir.me), Kevin van Zonneveld
7
+ * (http://kevin.vanzonneveld.net), Onno Marsman, Theriault, Michael White
8
+ * (http://getsprink.com), Waldo Malqui Silva, Paulo Freitas, Jonas Raoni
9
+ * Soares Silva (http://www.jsfromhell.com), Jack, Philip Peterson, Ates Goral
10
+ * (http://magnetiq.com), Legaev Andrey, Ratheous, Alex, Martijn Wieringa,
11
+ * lmeyrick (https://sourceforge.net/projects/bcmath-js/), Nate, Enrique
12
+ * Gonzalez, Philippe Baumann, Webtoolkit.info (http://www.webtoolkit.info/),
13
+ * Rafał Kukawski (http://blog.kukawski.pl), Ash Searle
14
+ * (http://hexmen.com/blog/), Ole Vrijenhoek, travc, Jani Hartikainen, Carlos
15
+ * R. L. Rodrigues (http://www.jsfromhell.com), stag019, GeekFG
16
+ * (http://geekfg.blogspot.com), WebDevHobo (http://webdevhobo.blogspot.com/),
17
+ * Erkekjetter,
18
+ * http://stackoverflow.com/questions/57803/how-to-convert-decimal-to-hex-in-javascript,
19
+ * Rafał Kukawski (http://blog.kukawski.pl/), T.Wild, pilus, marrtins,
20
+ * Michael Grier, Johnny Mast (http://www.phpvrouwen.nl), Andrea Giammarchi
21
+ * (http://webreflection.blogspot.com), d3x, Karol Kowalski, Robin, AJ, Joris,
22
+ * Steven Levithan (http://blog.stevenlevithan.com), Paul Smith, Arpad Ray
23
+ * (mailto:arpad@php.net), Kevin van Zonneveld
24
+ * (http://kevin.vanzonneveld.net/), gettimeofday, majak, Imgen Tata
25
+ * (http://www.myipdf.com/), Felix Geisendoerfer
26
+ * (http://www.debuggable.com/felix), Martin (http://www.erlenwiese.de/),
27
+ * mdsjack (http://www.mdsjack.bo.it), Tim de Koning
28
+ * (http://www.kingsquare.nl), KELAN, Mailfaker (http://www.weedem.fr/),
29
+ * felix, Michael White, Dreamer, Public Domain
30
+ * (http://www.json.org/json2.js), David, Nathan, Josh Fraser
31
+ * (http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/),
32
+ * Oleg Eremeev, Breaking Par Consulting Inc
33
+ * (http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256CFB006C45F7),
34
+ * Marc Palau, Mirek Slugen, Chris, Lars Fischer, Tyler Akins
35
+ * (http://rumkin.com), Aman Gupta, Thunder.m, Pellentesque Malesuada,
36
+ * saulius, Kankrelune (http://www.webfaktory.info/), Alfonso Jimenez
37
+ * (http://www.alfonsojimenez.com), Caio Ariede (http://caioariede.com),
38
+ * gorthaur, Diplom@t (http://difane.com/), Steve Hilder, Sakimori, Frank
39
+ * Forte, djmix, Nick Kolosov (http://sammy.ru), marc andreu, nobbler, Fox,
40
+ * Thiago Mata (http://thiagomata.blog.com), lmeyrick
41
+ * (https://sourceforge.net/projects/bcmath-js/this.), Douglas Crockford
42
+ * (http://javascript.crockford.com), mktime, Linuxworld, john
43
+ * (http://www.jd-tech.net), ger, Lincoln Ramsay, jmweb, duncan, date, Adam
44
+ * Wallner (http://web2.bitbaro.hu/), paulo kuong, Itsacon
45
+ * (http://www.itsacon.net/), Billy, vlado houba, Jalal Berrami, Francois,
46
+ * Scott Cariss, sankai, Denny Wardhana, Arno, Bayron Guevara, Mateusz
47
+ * "loonquawl" Zalega, Slawomir Kaniecki, ReverseSyntax, Oskar Larsson
48
+ * Högfeldt (http://oskar-lh.name/), Marco, madipta, echo is bad, 0m3r,
49
+ * T0bsn, Der Simon (http://innerdom.sourceforge.net/), Eugene Bulkin
50
+ * (http://doubleaw.com/), Subhasis Deb, JB, EdorFaus, XoraX
51
+ * (http://www.xorax.info), Ozh, Thomas Beaucourt (http://www.webapp.fr),
52
+ * David Randall, Bryan Elliott, JT, Brad Touesnard, nord_ua, Peter-Paul Koch
53
+ * (http://www.quirksmode.org/js/beat.html), MeEtc (http://yass.meetcweb.com),
54
+ * josh, LH, Stoyan Kyosev (http://www.svest.org/), Steve Clay, Pyerre,
55
+ * Gilbert, Jon Hohle, David James, Tim Wiel, noname, class_exists, T. Wild,
56
+ * Ole Vrijenhoek (http://www.nervous.nl/), Marc Jansen, Francesco, Soren
57
+ * Hansen, merabi, J A R, Shingo, Raphael (Ao RUDLER), Sanjoy Roy, kenneth,
58
+ * FremyCompany, stensi, Kristof Coomans (SCK-CEN Belgian Nucleair Research
59
+ * Centre), Devan Penner-Woelk, Pierre-Luc Paour, Martin Pool, Brant Messenger
60
+ * (http://www.brantmessenger.com/), Kirk Strobeck, Saulo Vallory, Christoph,
61
+ * Wagner B. Soares, Artur Tchernychev, Valentina De Rosa, Jason Wong
62
+ * (http://carrot.org/), Daniel Esteban, strftime, Rick Waldron, Mick@el,
63
+ * Bjorn Roesbeke (http://www.bjornroesbeke.be/), Bug?, Anton Ongson, Simon
64
+ * Willison (http://simonwillison.net), Marco van Oort, Gabriel Paderni, Blues
65
+ * (http://tech.bluesmoon.info/), Luke Godfrey, Tomasz Wesolowski, rezna, Eric
66
+ * Nagel, Evertjan Garretsen, Pul, Bobby Drake, uestla, Alan C, Ulrich,
67
+ * Zahlii, Yves Sucaet, sowberry, Norman "zEh" Fuchs, hitwork, johnrembo,
68
+ * Brian Tafoya (http://www.premasolutions.com/), Nick Callen, Steven Levithan
69
+ * (stevenlevithan.com), ejsanders, Scott Baker, Philippe Jausions
70
+ * (http://pear.php.net/user/jausions), Aidan Lister
71
+ * (http://aidanlister.com/), Rob, e-mike, HKM, ChaosNo1, metjay, strcasecmp,
72
+ * strcmp, Taras Bogach, jpfle, Alexander Ermolaev
73
+ * (http://snippets.dzone.com/user/AlexanderErmolaev), DxGx, kilops, Orlando,
74
+ * dptr1988, Le Torbi, James (http://www.james-bell.co.uk/), Pedro Tainha
75
+ * (http://www.pedrotainha.com), James, Philipp Lenssen, penutbutterjelly,
76
+ * jakes, 3D-GRAF, Yannoo, gabriel paderni, baris ozdil, FGFEmperor, daniel
77
+ * airton wermann (http://wermann.com.br), Atli Þór, Howard Yeend, Diogo
78
+ * Resende, Allan Jensen (http://www.winternet.no), Benjamin Lupton,
79
+ * Maximusya, davook, Greg Frazier, Tod Gentille, Manish, Matt Bradley, Cord,
80
+ * fearphage (http://http/my.opera.com/fearphage/), Matteo, Victor, taith, Tim
81
+ * de Koning, Alexander M Beedie, Ryan W Tenney (http://ryan.10e.us), Riddler
82
+ * (http://www.frontierwebdev.com/), T.J. Leahy, Luis Salazar
83
+ * (http://www.freaky-media.com/), Rafał Kukawski, Rival, Luke Smith
84
+ * (http://lucassmith.name), Jamie Beck (http://www.terabit.ca/), Ben
85
+ * (http://benblume.co.uk/), Russell Walker (http://www.nbill.co.uk/),
86
+ * Garagoth, Le Torbi (http://www.letorbi.de/), Andrej Pavlovic, DtTvB
87
+ * (http://dt.in.th/2008-09-16.string-length-in-bytes.html), Andreas, Chris
88
+ * McMacken, Arnout Kazemier (http://www.3rd-Eden.com), Michael, setcookie,
89
+ * Blues at http://hacks.bluesmoon.info/strftime/strftime.js, YUI Library:
90
+ * http://developer.yahoo.com/yui/docs/YAHOO.util.DateLocale.html, Dino, rem,
91
+ * incidence, Cagri Ekin, Amirouche, Amir Habibi
92
+ * (http://www.residence-mixte.com/), Kheang Hok Chin
93
+ * (http://www.distantia.ca/), Jay Klehr, booeyOH, Ben Bryan, William, Josep
94
+ * Sanz (http://www.ws3.es/), meo, Greenseed, Leslie Hoare, mk.keck, Yen-Wei
95
+ * Liu
96
+ * 
97
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
98
+ * and GPL (GPL-LICENSE.txt) licenses.
99
+ * 
100
+ * Permission is hereby granted, free of charge, to any person obtaining a
101
+ * copy of this software and associated documentation files (the
102
+ * "Software"), to deal in the Software without restriction, including
103
+ * without limitation the rights to use, copy, modify, merge, publish,
104
+ * distribute, sublicense, and/or sell copies of the Software, and to
105
+ * permit persons to whom the Software is furnished to do so, subject to
106
+ * the following conditions:
107
+ * 
108
+ * The above copyright notice and this permission notice shall be included
109
+ * in all copies or substantial portions of the Software.
110
+ * 
111
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
112
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
113
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
114
+ * IN NO EVENT SHALL KEVIN VAN ZONNEVELD BE LIABLE FOR ANY CLAIM, DAMAGES
115
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
116
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
117
+ * OTHER DEALINGS IN THE SOFTWARE.
118
+ */ 
119
+
120
+function utf8_encode (argString) {
121
+    // http://kevin.vanzonneveld.net
122
+    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
123
+    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
124
+    // +   improved by: sowberry
125
+    // +    tweaked by: Jack
126
+    // +   bugfixed by: Onno Marsman
127
+    // +   improved by: Yves Sucaet
128
+    // +   bugfixed by: Onno Marsman
129
+    // +   bugfixed by: Ulrich
130
+    // *     example 1: utf8_encode('Kevin van Zonneveld');
131
+    // *     returns 1: 'Kevin van Zonneveld'
132
+    var string = (argString + ''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
133
+    var utftext = "",
134
+        start, end, stringl = 0;
135
+
136
+    start = end = 0;
137
+    stringl = string.length;
138
+    for (var n = 0; n < stringl; n++) {
139
+        var c1 = string.charCodeAt(n);
140
+        var enc = null;
141
+
142
+        if (c1 < 128) {
143
+            end++;
144
+        } else if (c1 > 127 && c1 < 2048) {
145
+            enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
146
+        } else {
147
+            enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
148
+        }
149
+        if (enc !== null) {
150
+            if (end > start) {
151
+                utftext += string.slice(start, end);
152
+            }
153
+            utftext += enc;
154
+            start = end = n + 1;
155
+        }
156
+    }
157
+
158
+    if (end > start) {
159
+        utftext += string.slice(start, stringl);
160
+    }
161
+
162
+    return utftext;
163
+}
164
+
165
+function crc32 (str) {
166
+    // http://kevin.vanzonneveld.net
167
+    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
168
+    // +   improved by: T0bsn
169
+    // -    depends on: utf8_encode
170
+    // *     example 1: crc32('Kevin van Zonneveld');
171
+    // *     returns 1: 1249991249
172
+    str = this.utf8_encode(str);
173
+    var table = "00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D";
174
+
175
+    var crc = 0;
176
+    var x = 0;
177
+    var y = 0;
178
+
179
+    crc = crc ^ (-1);
180
+    for (var i = 0, iTop = str.length; i < iTop; i++) {
181
+        y = (crc ^ str.charCodeAt(i)) & 0xFF;
182
+        x = "0x" + table.substr(y * 9, 8);
183
+        crc = (crc >>> 8) ^ x;
184
+    }
185
+
186
+    return crc ^ (-1);
187
+}
188
+
0 189
new file mode 100644
... ...
@@ -0,0 +1,101 @@
0
+<!DOCTYPE html>
1
+<html>
2
+<head>
3
+<meta name="description" content="devnewton passgrid generator" />
4
+<meta name="author" content="devnewton <devnewton@tuxfamily.org>" />
5
+<meta name="licence" content="CC-BY ( http://creativecommons.org/licenses/by/3.0/legalcode )" />
6
+<meta http-equiv="content-type" content="text/html; charset=UTF-8"></meta>
7
+<title>Devnewton passgrid generator</title>
8
+</head>
9
+<style type="text/css">
10
+	table {
11
+		font-family: monospace;
12
+		width: 8cm;
13
+		height: 6cm;
14
+		border-collapse: collapse;
15
+		border: 1px solid black;
16
+		float: left;
17
+        page-break-inside : avoid;
18
+        margin: 2mm;
19
+	}
20
+	th {
21
+		background-color: #CCCCFF;
22
+		font-size: 0.8em;
23
+	}
24
+	td {
25
+		text-align: center;
26
+		vertical-align: middle;
27
+		border-bottom: dotted 1px black;	
28
+	}
29
+	td.yep {
30
+		background-color: #CCCCCC;
31
+	}
32
+</style>
33
+
34
+<style type="text/css" media="print">
35
+	table {
36
+        font-size:1.8mm;
37
+        line-height:2mm
38
+		font-family: monospace;
39
+		width: 5.5cm;
40
+		height: 8cm;
41
+        table-layout: fixed; 
42
+		border-collapse: collapse;
43
+		border: 1px solid black;
44
+        page-break-inside : avoid;
45
+        margin: 0.0mm;
46
+        padding: 0mm 0mm 0mm 0mm; 
47
+	}
48
+	th {
49
+		background-color: #CCCCFF;
50
+
51
+		font-size: 1.5mm;
52
+        height: 1.8mm;
53
+        margin: 0.0mm;
54
+        padding: 0mm 0mm 0mm 0mm; 
55
+	}
56
+	td {
57
+		text-align: center;
58
+		vertical-align: middle;
59
+		border-bottom: dotted 1px black;
60
+        height: 1.8mm;
61
+        margin: 0.0mm;
62
+        padding: 0mm 0mm 0mm 0mm; 
63
+	}
64
+	td.yep {
65
+		background-color: #CCCCCC;
66
+	}
67
+    form
68
+    {
69
+            display:none;
70
+    }
71
+</style>
72
+<body>
73
+<form name="passgrid_form">
74
+    <h1>Générateur de <a href="http://www.vvsss.com/grid/">passgrids</a></h1>
75
+    <h2>Qu'est qu'une passgrid?</h2>
76
+        <p>Une passgrid est une façon de conserver un mot de passe. C'est une grille contenant des chiffres, des lettres ou des symboles. Le mot de passe se situe sur la grille. Au lieu de mémoriser le mot de passe, vous devez vous souvenir des cases de la grille constituant ce mot de passe. Par exemple: en partant de la case 2,3, 4 cases à gauche, puis 4 cases en bas.</p>
77
+    <p>Pour une explication complète, consultez cette <a href="http://www.vvsss.com/grid/">page</a></p>
78
+    <h2>Quel est l'intérêt?</h2>
79
+        <ul>
80
+            <li>Il suffit de mémoriser les cases constituant le mot de passe et d'utiliser plusieurs grilles pour retenir simplement tous vos mots de passe.</li>
81
+            <li>Si quelqu'un trouve vos passgrids, il lui sera quasiment impossible de trouver vos mots de passe.</li>
82
+            <li>Les agents secrets peuvent détruire leurs passgrids avant d'être fait prisonnier et ne pas révéler leurs mots de passe, même sous la torture.</li>
83
+        </ul> 
84
+    <h2>Comment créer des passgrids?</h2>
85
+    En utilisant le générateur ci-dessous et en imprimant la page après avoir cliquer sur le bouton <em>Créer les passgrids</em>. Ce générateur est écrit en HTML/Javascript. Vous pouvez enregistrer cette page et l'utiliser hors ligne.
86
+    <h1>Générer une ou plusieurs passgrids</h1>
87
+    Identifiants: <input name="passgrid_source" value="passgrid1,passgrid2,passgrid3" type="text" title="Liste de mots séparés par des virgules qui vont servir à générer les grilles. Le plus simple est d'utiliser les identifiants qui correspondent aux mots de passe : moncompte@monmail.com,logindemonpc,toto" />
88
+    Caractères possibles: <input name="passgrid_chars" value="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz" type="text" />
89
+    Nombre de lignes: <input name="passgrid_rows" value="26" type="text" />
90
+    Nombre de colonnes: <input name="passgrid_cols" value="10" type="text" />
91
+    <input value="Créer les passgrids" onclick="generatePassgrids();" type="button" />
92
+</form>
93
+
94
+    <script src="mt.js" type="text/javascript"></script>
95
+    <script src="crc32.js" type="text/javascript"></script>
96
+    <script src="passgrid.js" type="text/javascript"></script>
97
+    <div id="printable_passgrids"></div>
98
+</body>
99
+
100
+</html>
0 101
new file mode 100644
... ...
@@ -0,0 +1,209 @@
0
+// mt.js 0.2.4 (2005-12-23)
1
+
2
+/*
3
+
4
+Mersenne Twister in JavaScript based on "mt19937ar.c"
5
+
6
+ * JavaScript version by Magicant: Copyright (C) 2005 Magicant
7
+
8
+
9
+ * Original C version by Makoto Matsumoto and Takuji Nishimura
10
+   http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/mt.html
11
+
12
+Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
13
+All rights reserved.
14
+
15
+Redistribution and use in source and binary forms, with or without
16
+modification, are permitted provided that the following conditions
17
+are met:
18
+
19
+  1. Redistributions of source code must retain the above copyright
20
+     notice, this list of conditions and the following disclaimer.
21
+
22
+  2. Redistributions in binary form must reproduce the above copyright
23
+     notice, this list of conditions and the following disclaimer in the
24
+     documentation and/or other materials provided with the distribution.
25
+
26
+  3. The names of its contributors may not be used to endorse or promote 
27
+     products derived from this software without specific prior written 
28
+     permission.
29
+
30
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33
+A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
37
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
38
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
39
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
+
42
+*/
43
+
44
+
45
+// Methods whose name starts with "_" are private methods.
46
+// Don't call them externally!
47
+
48
+
49
+/**
50
+ * Constructor: MersenneTwister([integer/Array<integer> seed])
51
+ * initializes the object with the given seed.
52
+ * The seed may be an integer or an array of integers.
53
+ * If the seed is not given, the object will be initialized with the current
54
+ * time: new Date().getTime().
55
+ * See also: setSeed(seed).
56
+ */
57
+function MersenneTwister(seed) {
58
+	if (arguments.length == 0)
59
+		seed = new Date().getTime();
60
+	
61
+	this._mt = new Array(624);
62
+	this.setSeed(seed);
63
+}
64
+
65
+/** multiplies two uint32 values and returns a uint32 result. */
66
+MersenneTwister._mulUint32 = function(a, b) {
67
+	var a1 = a >>> 16, a2 = a & 0xffff;
68
+	var b1 = b >>> 16, b2 = b & 0xffff;
69
+	return (((a1 * b2 + a2 * b1) << 16) + a2 * b2) >>> 0;
70
+};
71
+
72
+/** returns ceil(value) if value is finite number, otherwise 0. */
73
+MersenneTwister._toNumber = function(x) {
74
+	return (typeof x == "number" && !isNaN(x)) ? Math.ceil(x) : 0;
75
+};
76
+
77
+/**
78
+ * Method: setSeed(integer/Array<integer> seed)
79
+ * resets the seed. The seed may be an integer or an array of integers.
80
+ * Elements in the seed array that are not numbers will be treated as 0.
81
+ * Numbers that are not integers will be rounded down.
82
+ * The integer(s) should be greater than or equal to 0 and less than 2^32.
83
+ * This method is compatible with init_genrand and init_by_array function of
84
+ * the original C version.
85
+ */
86
+MersenneTwister.prototype.setSeed = function(seed) {
87
+	var mt = this._mt;
88
+	if (typeof seed == "number") {
89
+		mt[0] = seed >>> 0;
90
+		for (var i = 1; i < mt.length; i++) {
91
+			var x = mt[i-1] ^ (mt[i-1] >>> 30);
92
+			mt[i] = MersenneTwister._mulUint32(1812433253, x) + i;
93
+		}
94
+		this._index = mt.length;
95
+	} else if (seed instanceof Array) {
96
+		var i = 1, j = 0;
97
+		this.setSeed(19650218);
98
+		for (var k = Math.max(mt.length, seed.length); k > 0; k--) {
99
+			var x = mt[i-1] ^ (mt[i-1] >>> 30);
100
+			x = MersenneTwister._mulUint32(x, 1664525);
101
+			mt[i] = (mt[i] ^ x) + (seed[j] >>> 0) + j;
102
+			if (++i >= mt.length) {
103
+				mt[0] = mt[mt.length-1];
104
+				i = 1;
105
+			}
106
+			if (++j >= seed.length) {
107
+				j = 0;
108
+			}
109
+		}
110
+		for (var k = mt.length - 1; k > 0; k--) {
111
+			var x = mt[i-1] ^ (mt[i-1] >>> 30);
112
+			x = MersenneTwister._mulUint32(x, 1566083941);
113
+			mt[i] = (mt[i] ^ x) - i;
114
+			if (++i >= mt.length) {
115
+				mt[0] = mt[mt.length-1];
116
+				i = 1;
117
+			}
118
+		}
119
+		mt[0] = 0x80000000;
120
+	} else {
121
+		throw new TypeError("MersenneTwister: illegal seed.");
122
+	}
123
+};
124
+
125
+/** returns the next random Uint32 value. */
126
+MersenneTwister.prototype._nextInt = function() {
127
+	var mt = this._mt, value;
128
+	
129
+	if (this._index >= mt.length) {
130
+		var k = 0, N = mt.length, M = 397;
131
+		do {
132
+			value = (mt[k] & 0x80000000) | (mt[k+1] & 0x7fffffff);
133
+			mt[k] = mt[k+M] ^ (value >>> 1) ^ ((value & 1) ? 0x9908b0df : 0);
134
+		} while (++k < N-M);
135
+		do {
136
+			value = (mt[k] & 0x80000000) | (mt[k+1] & 0x7fffffff);
137
+			mt[k] = mt[k+M-N] ^ (value >>> 1) ^ ((value & 1) ? 0x9908b0df : 0);
138
+		} while (++k < N-1);
139
+		value = (mt[N-1] & 0x80000000) | (mt[0] & 0x7fffffff);
140
+		mt[N-1] = mt[M-1] ^ (value >>> 1) ^ ((value & 1) ? 0x9908b0df : 0);
141
+		this._index = 0;
142
+	}
143
+	
144
+	value = mt[this._index++];
145
+	value ^=  value >>> 11;
146
+	value ^= (value <<   7) & 0x9d2c5680;
147
+	value ^= (value <<  15) & 0xefc60000;
148
+	value ^=  value >>> 18;
149
+	return value >>> 0;
150
+};
151
+
152
+/**
153
+ * Method: nextInt([[number min,] number max])
154
+ * returns a random integer that is greater than or equal to min and less than
155
+ * max. The value of (max - min) must be positive number less or equal to 2^32.
156
+ * If min is not given or not a number, this method uses 0 for min.
157
+ * If neither of min and max is given or max is out of range, this method
158
+ * uses 2^32 for max.
159
+ * This method is compatible with genrand_int32 function of the original C
160
+ * version for min=0 & max=2^32, but not with genrand_int31 function.
161
+ */
162
+MersenneTwister.prototype.nextInt = function() {
163
+	var min, sup;
164
+	switch (arguments.length) {
165
+	case 0:
166
+		return this._nextInt();
167
+	case 1:
168
+		min = 0;
169
+		sup = MersenneTwister._toNumber(arguments[0]);
170
+		break;
171
+	default:
172
+		min = MersenneTwister._toNumber(arguments[0]);
173
+		sup = MersenneTwister._toNumber(arguments[1]) - min;
174
+		break;
175
+	}
176
+	
177
+	if (!(0 < sup && sup < 0x100000000))
178
+		return this._nextInt() + min;
179
+	if ((sup & (~sup + 1)) == sup)
180
+		return ((sup - 1) & this._nextInt()) + min;
181
+	
182
+	var value;
183
+	do {
184
+		value = this._nextInt();
185
+	} while (sup > 4294967296 - (value - (value %= sup)));
186
+	return value + min;
187
+};
188
+
189
+/**
190
+ * Method: next()
191
+ * returns a random number that is greater than or equal to 0 and less than 1.
192
+ * This method is compatible with genrand_res53 function of the original C
193
+ * version.
194
+ */
195
+MersenneTwister.prototype.next = function() {
196
+	var a = this._nextInt() >>> 5, b = this._nextInt() >>> 6;
197
+	return (a * 0x4000000 + b) / 0x20000000000000; 
198
+};
199
+
200
+/**
201
+ * Method: nextChar( chars)
202
+ * returns a random char between chars
203
+ * Exemple: mt.nextChar( "abc" )
204
+ */
205
+MersenneTwister.prototype.nextChar = function( chars ) {
206
+    var n = this.nextInt( chars.length );
207
+    return chars.substring(n,n+1);
208
+}
0 209
new file mode 100644
... ...
@@ -0,0 +1,53 @@
0
+/** devnewton passgrid generator
1
+
2
+Author: devnewton <devnewton@tuxfamily.org>
3
+Licence: CC-BY ( http://creativecommons.org/licenses/by/3.0/legalcode )
4
+**/
5
+generatePassgrids = function() {
6
+    var generatePassgrid = function( source ) {
7
+        var nbRow = parseInt( document.forms.passgrid_form.passgrid_rows.value );
8
+        var nbCol = parseInt( document.forms.passgrid_form.passgrid_cols.value );
9
+        if( isNaN( nbRow ) || isNaN( nbCol ) ) {
10
+            throw "Incorrect row or column number";
11
+        }
12
+        var seed = crc32( source );
13
+        var mt = new MersenneTwister( seed );
14
+        var out = "";
15
+        var yep = true
16
+        out += "<p><table>";
17
+        out += "<tr><td colspan=\""+ (nbCol+1) + "\">" + source + "</td></tr>";
18
+        
19
+        out += "<tr><th></th>";
20
+        for( var c = 0; c<nbCol; c++ ) {
21
+            out+="<th>" + (c+1) + "</th>";
22
+        }
23
+        out += "</tr>";
24
+        
25
+        for( var r = 0; r<nbRow; r++ ) {
26
+            out += "<tr>";
27
+            out += "<th>" + (r+1) + "</th>";
28
+            for( var c = 0; c<nbCol; c++ ) {
29
+                if( yep )
30
+                    out += "<td>";
31
+                else
32
+                    out += "<td class=\"yep\">";
33
+                yep = !yep;
34
+                
35
+                out += mt.nextChar( document.forms.passgrid_form.passgrid_chars.value );
36
+                out += "</td>";
37
+            }
38
+            if( (nbCol % 2) == 0 )
39
+                yep = !yep;
40
+            out += "</tr>";
41
+        }
42
+        out += "</table></p>";
43
+        return out
44
+    }
45
+    
46
+    var sources = document.forms.passgrid_form.passgrid_source.value.split( "," );
47
+    var outElement = document.getElementById('printable_passgrids')
48
+    outElement.innerHTML = ""
49
+	for (var i=0; i<sources.length; i++) {
50
+       outElement.innerHTML += generatePassgrid( sources[ i ] );
51
+	}
52
+}