Effect of brute force guessing a password

String appears after multiple random symbols uncover it

by Sergei Sokolov

HTML

<div id="effect"></div>

CSS

body{  background-color: #333}
#effect {
  font-family: Courier New,monospace;
  height: 26px;
  line-height: 30px;
  color:#0C0;
  }

JavaScript

(function( nick, el) {
  var L = nick.length
    ,cursor = 0
    ,arr
    ,timeout
    ,prob = 0.1 // вероятность "разгадывания" очередной позиции
    ,rate = 10  // частота "кадров" в секунду
    ,delay = 1000 / rate
    ,alphabet = []
    ,i
    ,aL
  ;
  
  // заполним алфавит из которого брать случайные символы
  for(i=128;i<=255;i++) alphabet.push( String.fromCharCode(i));
  for(i=1024;i<=1279;i++) alphabet.push( String.fromCharCode(i));
  aL = alphabet.length;

  function tweak() {  
    arr = nick.split('');
    for(pos = cursor; pos < L; pos++) {
      arr[pos] = alphabet[ Math.floor( aL * Math.random())];
    }
    el.innerText = arr.join('');
    
    if( cursor === L) return; // done
    
    if( Math.random() < prob) cursor++;
    timeout = window.setTimeout( tweak, delay);
  }

  tweak();
  
})( "Sergei Sokolov", document.getElementById("effect") )