qString: パスワードを生成
12文字のパスワードを生成します。”23456789″ から2文字、”ACFGHJKNRSUXYZ” から4文字、”acfghjknrsuxyz” から4文字、”#$%&+-” から2文字をランダム抽出します。誤認されやすい文字(”1″ や “l” など)は抽出されません。
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>
自由改変可能な HTML/JavaScript コードです (MIT License)。いかなる保証もありません。
Capture

