qString: Generate Password

qString: Generate Password

qString: パスワードを生成

Generates a 12-character password. Randomly extracts 2 characters from “23456789”, 4 characters from “ACFGHJKNRSUXYZ”, 4 characters from “acfghjknrsuxyz”, and 2 characters from “#$%&+-“. Characters that are easily misidentified (e.g., “1” and “l”) are not extracted.

Input / Output

→ qString (STRING_TEXTFIELD) q_NewPassword

Code Example

HTML/JavaScript (click to close)
<button type="button" 
 onclick="user_overwriteRandomPasswordToQstr (
            'q_NewPassword'
          )"> Generate Password </button>
 ※ Click to Overwrite / クリックで上書き

<script>
function user_overwriteRandomPasswordToQstr ( qStrFieldName ) {
  const strNumeric = "23456789";        const numNumeric = 2;
  const strUpper   = "ACFGHJKNRSUXYZ";  const numUpper   = 4;
  const strLower   = "acfghjknrsuxyz";  const numLower   = 4;
  const strSymbol  = "#$%&+-";          const numSymbol  = 2;

  let strPwd = "";
  for( let i = 0; i < numNumeric; i++ ){
    strPwd  += strNumeric.charAt( Math.floor( Math.random() * strNumeric.length ) );
  }
  for( let i = 0; i < numUpper; i++ ){
    strPwd  += strUpper.charAt(   Math.floor( Math.random() * strUpper.length ) );
  }
  for( let i = 0; i < numLower; i++ ){
    strPwd  += strLower.charAt(   Math.floor( Math.random() * strLower.length ) );
  }
  for( let i = 0; i < numSymbol; i++ ){
    strPwd  += strSymbol.charAt(  Math.floor( Math.random() * strSymbol.length ) );
  }

  let arrPwd = strPwd.split("");
  let j = arrPwd.length;
  while ( j > 1 ) {  // shuffle (Fisher-Yates)
    let k = Math.floor( Math.random() * j );
    j = j - 1;
    if (j === k) continue;
    let charTmp = arrPwd[j];
    arrPwd[j]   = arrPwd[k];
    arrPwd[k]   = charTmp;
  }

  qbpms.form.set( qStrFieldName, arrPwd.join("") ); // update the input form of Questetra
}
</script>
warning Freely modifiable HTML/JavaScript code, MIT License. No warranty of any kind.
(Decoration using JavaScript is only available in the Professional edition: M213)

Capture

Generates a 12-character password. Randomly extracts 2 characters from "23456789", 4 characters from "ACFGHJKNRSUXYZ", 4 characters from "acfghjknrsuxyz", and 2 characters from "#$%&+-". Characters that are easily misidentified (e.g., "1" and "l") are not extracted.

Online DEMO (public form)

See Also

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d