|
1 | 1 | <html>
|
2 | 2 | <body>
|
3 |
| -<img src="canvas2.png"> |
| 3 | +<input type="file" id="img" accept="image/png"> |
| 4 | +<button onclick="makeImg()">Decode It</button> |
4 | 5 | <script type="text/javascript">
|
5 | 6 | var contextNode=null;
|
| 7 | +var redIndicies=[]; |
| 8 | +function makeImg() |
| 9 | +{ |
| 10 | +var outerImg=document.getElementById("img"); |
| 11 | +if(!outerImg.files[0]) |
| 12 | +{ |
| 13 | +return; |
| 14 | +} |
| 15 | +var imgdat=outerImg.files[0]; |
| 16 | +var reader = new FileReader(); |
| 17 | +reader.onload=function(event) |
| 18 | +{ |
| 19 | +var img=new Image; |
| 20 | +img.onload=function() |
| 21 | +{ |
| 22 | +doThings(this); |
| 23 | +} |
| 24 | +img.src=event.target.result; |
| 25 | +} |
| 26 | +reader.readAsDataURL(imgdat); |
| 27 | +} |
6 | 28 | function base64_encode (data,isutf8) {
|
7 | 29 | // Encodes string using MIME base64 algorithm
|
8 | 30 | //
|
|
53 | 75 | var randnum=Math.floor(rng()*newData.length);
|
54 | 76 | var redIndex=randnum-(randnum%4);
|
55 | 77 | var name="";
|
| 78 | + |
56 | 79 | if(newData[redIndex]==-1)
|
57 | 80 | {
|
58 | 81 | return getName(rng,imageData,newData,deletedbytes);
|
59 | 82 | }
|
60 | 83 | len=((imageData[redIndex] & 7)<<5 | (imageData[redIndex+1] & 3)<<3 |(imageData[redIndex+2] & 7));
|
| 84 | +//redIndicies.push(redIndex); |
61 | 85 | newData[redIndex]=-1;
|
62 | 86 | deletedbytes++;
|
63 | 87 | for(var i=0;i<len;i++)
|
|
70 | 94 | i--;
|
71 | 95 | continue;
|
72 | 96 | }
|
| 97 | +//redIndicies.push(redIndex); |
73 | 98 | byte=((imageData[redIndex] & 7)<<5 | (imageData[redIndex+1] & 3)<<3 |(imageData[redIndex+2] & 7));
|
74 | 99 | name+=String.fromCharCode(byte);
|
75 | 100 | newData[redIndex]=-1;
|
|
89 | 114 | i--;
|
90 | 115 | continue;
|
91 | 116 | }
|
| 117 | +//redIndicies.push(redIndex); |
92 | 118 | byte=((imageData[redIndex] & 7)<<5 | (imageData[redIndex+1] & 3)<<3 |(imageData[redIndex+2] & 7));
|
93 | 119 | len|=byte<<(i*8);
|
94 | 120 | newData[redIndex]=-1;
|
|
189 | 215 | } (Array.prototype.slice.call(arguments)));
|
190 | 216 | };
|
191 | 217 |
|
192 |
| -function doThings() |
193 |
| -{ |
194 |
| -if(!contextNode) |
| 218 | +function doThings(img) |
195 | 219 | {
|
196 |
| -return; |
197 |
| -} |
198 | 220 | var canvas = null,
|
199 | 221 | ctx = null,
|
200 | 222 | canvas = document.createElement("canvas");
|
|
203 | 225 | var b = document.getElementsByTagName("body")[0];
|
204 | 226 | b.appendChild(canvas);
|
205 | 227 | ctx = canvas.getContext("2d");
|
206 |
| -var img = contextNode; |
207 | 228 | // apply the width and height to the canvas element
|
208 | 229 | canvas.width = img.width;
|
209 | 230 | canvas.height = img.height;
|
|
238 | 259 | retObj=getBodyLength(rng,imageData,newData,deletedbytes);
|
239 | 260 | newData=retObj.newData;
|
240 | 261 | len=retObj["len"];
|
| 262 | + |
241 | 263 | for(var i = 0; i < len; i++){
|
242 | 264 | var randnum=Math.floor(rng()*newData.length);
|
243 | 265 | var redIndex=randnum-(randnum%4);
|
|
247 | 269 | i--;
|
248 | 270 | continue;
|
249 | 271 | }
|
| 272 | +//redIndicies.push(redIndex); |
250 | 273 | byte=((imageData[redIndex] & 7)<<5 | (imageData[redIndex+1] & 3)<<3 |(imageData[redIndex+2] & 7));
|
251 | 274 | body+=String.fromCharCode(byte);
|
252 | 275 | newData[redIndex]=-1;
|
253 | 276 | deletedbytes++;
|
254 | 277 | }
|
| 278 | +//alert(redIndicies); |
255 | 279 | var base64string=base64_encode(body,true);
|
256 | 280 | url="data:application/octet-stream;base64,"+base64string;
|
257 | 281 | var theif=document.createElement("iframe");
|
|
0 commit comments