Block Z 10
Block system for creating other functions. By Joaquim Pedro de Morais Filho (zicutake@mail.ru).
Search This Blog
Thursday, March 11, 2021
Generate BlockZ10 via Javascript
API by Joaquim Pedro de Morais Filho 11/03/2021 (Brasil) (pedrodefilho@hotmail.com)
<script> var Password = { _pattern : /[x-xX-X]/, _getRandomByte : function() { // http://caniuse.com/#feat=getrandomvalues if(window.crypto && window.crypto.getRandomValues) { var result = new Uint8Array(1); window.crypto.getRandomValues(result); return result[0]; } else if(window.msCrypto && window.msCrypto.getRandomValues) { var result = new Uint8Array(1); window.msCrypto.getRandomValues(result); return result[0]; } else { return Math.floor(Math.random() * 256); } }, generate : function(length) { return Array.apply(null, {'length': length}) .map(function() { var result; while(true) { result = String.fromCharCode(this._getRandomByte()); if(this._pattern.test(result)) { return result; } } }, this) .join(''); } };</script> <input id="p" type="text" /><br /> <input onclick="document.getElementById("p").value = Password.generate(10)" type="button" value="generate" />
Newer Posts
Older Posts
Home