SOURCE

console 命令行工具 X clear

                    
>
console
$('#tempBtn,#perBtn').on('click',e=>{
    genPwd(e.target.id);
});

function genPwd(id){
    let t=$('#time').val()?+new Date($('#time').val()):+new Date();
    let d=getDateStr(new Date(t+3600000));
    if(id=='tempBtn'){
        $('#tempSpan').text(d+'前有效  '+encode(t+'676'));
         $('#perSpan').text('');
    }else  if(id=='perBtn'){
        $('#perSpan').text(d+'前有效  '+encode(t+'zyy'));
        $('#tempSpan').text('');
    }
}

function encode(str) {
    return btoa(unescape(encodeURIComponent(btoa(unescape(encodeURIComponent(str))))))
}

function getDateStr(d=new Date()){
	return d.toLocaleDateString()+' '+d.toTimeString().replace(/ .+$/,'');
}
<form onsubmit="return false;">
    <label >请输入时间:<input type="text" placeholder="留空则使用当前时间" id="time"> </label>
  <input type="submit" id="tempBtn" value="生成临时">
  <input type="submit" id="perBtn" value="生成永久">
  </br>
  </br>
   <label >临时密码:<span id="tempSpan"> </span></label>
   </br>
    <label>永久密码:<span id="perSpan"> </span></label>
</form>

本项目引用的自定义外部资源