Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

随机函数ASCII转换(更新版) #6

Open
1NI opened this issue Oct 30, 2016 · 0 comments
Open

随机函数ASCII转换(更新版) #6

1NI opened this issue Oct 30, 2016 · 0 comments

Comments

@1NI
Copy link

1NI commented Oct 30, 2016

基础版:

 <script>
function DAxie(){
  string="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  return string[Math.floor(Math.random()*26)]
}
function XIAOxie(){
  string="ABCDEFGHIJKLMNOPQRSTUVWXYZ".toLowerCase
  return string[Math.floor(Math.random()*26)]
}
function number(){
  string="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  return string[Math.floor(Math.random()*10)]
}
function SIX(){
    s=""
    for(i=1;i<=6;i++){
        v=[DAxie(),XIAOxie(),number()](随机函数集合)
        s=s+v[Math.floor(Math.random()*3)]
        }
         return s
    }
 </script>

ASCII基础版

<script>
function suiji(){
    c=""
    v=""
    for(i=1;i<=6;i++){
        s=Math.floor(Math.random()*75+48)(ASCII码为48-122之间)
        if(s<=57){
            c=String.fromCharCode(s)(数字与ASCII之间的转换)
            }
        else if(s>=65&&s<=90){
            c=String.fromCharCode(s)
            }
        else if(s>=97){
            c=String.fromCharCode(s)
            }
        else{
            c=""
            i=i-1
            }
            v=v+c
    }
    return v

}
</script>

ASCII进阶版

<script>
function suiji(){
    c=""
    v=""
    for(i=1;i<=6;i++){
        s=Math.floor(Math.random()*75+48)
        if(s<=57||s>=97||(s>=65&&s<=90)){
            v=v+String.fromCharCode(s)
            }
        else{
            i=i-1(重取ASCII)
            }
    }
    return v
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant