Answers for "javascript generate random key"

23

javascript generate random string

var crypto = require("crypto");
var id = crypto.randomBytes(20).toString('hex');

// "bb5dc8842ca31d4603d6aa11448d1654"
Posted by: Guest on July-16-2020
7

random string js

const string_length = 10
[...Array(string_length)].map(i=>(~~(Math.random()*36)).toString(36)).join('')
Posted by: Guest on September-04-2020
2

how to generate random string in javascript

Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
Posted by: Guest on June-13-2020
0

generate random key in javascript

<h6>Content 1:</h6>
<textarea class="content1" name="content1" id= "content1" spellcheck="false" onclick="content1()" readonly></textarea>
<h6>Content 2:</h6>
<input type="text" class="content2" name="content2" id= "content2" spellcheck="false" onclick="content1()" readonly>


<script>
var random_generator1 = document.getElementById('content1') 
random_generator1.innerHTML = create_random_generator(10) 
var random_generator2 = document.getElementById('content2') 
random_generator2.innerHTML = create_random_generator(20) 
                                        
function create_random_generator(string_length){
    var random_string = ''
    var char = 'abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    var i
    
    for(i = 0; i < string_length; i++){
        random_string = random_string + char.charAt(Math.floor(Math.random()* char.length))
    }
    return random_string
}
</script>
Posted by: Guest on June-02-2021

Code answers related to "javascript generate random key"

Code answers related to "Javascript"

Browse Popular Code Answers by Language