Показать сообщение отдельно
  #11 (permalink)  
Старый 15.01.2018, 18:16
Профессор
Отправить личное сообщение для clecar Посмотреть профиль Найти все сообщения от clecar
 
Регистрация: 11.02.2015
Сообщений: 254

<center><p><h2>СОХРАНЕНИЕ ТЕКСТА В ФАЙЛЕ PNG.</h2></p></center>

<input type="text"   id="b"  style='position: absolute; background:#faf; top:60px; left:270px; width:800px; ' >
<div id='сод' style='position: absolute; background:#fdd; padding: 10px; word-break: break-all; overflow-y: scroll; font-size: 18px; top:110px; left:270px; width:800px; height:500px;'></div>
<div style='position: absolute; text-align: center;  font-size: 18px;background:#ccf; top:110px; left:10px; width:250px; height:500px;'>
<img id='ш' src='./r1.png' />
<canvas id='прячу' width="100" height="100"></canvas><br><br>
<div id='инф'>0</div><br>
<input type="button"   value="очистиь" onclick="и.прячу.width=и.прячу.width; и.сод.innerHTML='';
и.b.value=''; и.b.focus();">
<input type="button"   value="запомнить" onclick="тор(); "><br><br>
<input type="button"   value="посмотреть" onclick="дешифратор(); "><br><br>
<input type="button" value="обновить" onclick="location.reload(); "><br>
После загрузки этой страницы нажмите <b>обновить</b> затем кнопку <b>посмотреть</b>
</div>

<script>
var и=document.all;
var номер=0;
var знак=[];
var текст=и.прячу.getContext('2d');
 текст.drawImage((и.ш),0,0,100,100);
  var imgd = текст.getImageData(0, 0, 100, 100);
 pix = imgd.data;
var буквы = [' ','ё',"й","ц","у","к","е","н","г","ш","щ","з","х","ъ","ф","ы","в","а","п","р","о","л","д","ж","э","я","ч","с","м","и","т","ь","б","ю",'1','2','3','4','5','6','7','8','9','0','-','+','=',";","'",'#','№','%','&','?','*','(',')','{','}','<','>','|','/',':','_',',','.','"','Ё','Й','Ц','У','К','Е','Н','Г','Ш','Щ','З','Х','Ъ','Ф','Ы','В','А','П','Р','О','Л','Д','Ж','Э','Я','Ч','С','','М','И','Т','Ь','Б','Ю','Q','W','E','R','T','Y','U','I','O','P','A','S','D','F','G','H','J','K','L','Z','X','C','V','B','N','M',"q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"];
var знач=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,70,71,72,73,74,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162];
var k=0; и.b.focus();
 function тор(e){
 var t=и.b.value; 
и.инф.innerHTML='length = '+t.length;
 var d=t.length;
 for(n=0,m=40000;n<m; n+=4){pix[n+3]=255; pix[n+1]=255; pix[n+2]=0; pix[n]=0;}
 var u=0;
for(na=0,ma=40000;na<ma;na++){ 
k++; if(k==1){k=0; na+=3;}
for(no=0,mo=162;no<mo;no++){if(t.charAt(u)==буквы[no]){pix[na]=знач[no]; break;}
if(t.charAt(u)=='['){pix[na]=200;} 
  if(t.charAt(u)==']'){pix[na]=199;}
 if(t.charAt(u)=='_'){pix[na]=197;}
 }
текст.putImageData(imgd, 0, 0);
u++; if(u>d){break;}
}
}
 function дешифратор(){
for(n=0, m=40000; n<m; n++){
for(na=0, ma=162; na<ma; na++){
if(pix[n]==знач[na]){и.сод.innerHTML+=буквы[na];}	
  }
if(pix[n]==200){и.сод.innerHTML+='['; }
if(pix[n]==199){и.сод.innerHTML+=']'; }
if(pix[n]==197){и.сод.innerHTML+='_'; }
}
var t=и.сод.innerHTML; 
и.инф.innerHTML='length = '+t.length;
}
</script>
Ответить с цитированием