init commit
This commit is contained in:
commit
87952f36ff
8 changed files with 1910 additions and 0 deletions
90
public/register.html
Normal file
90
public/register.html
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>RSSSSA - Keygen</title>
|
||||
</head>
|
||||
<body style="display: flex; flex-direction: column; align-items: center; text-align: center;">
|
||||
<h1>Rainbownapkins's Super Stupid Simple Stream Authenticator</h1>
|
||||
<h2 style="margin-bottom: 0;">Your stream key hash:</h2>
|
||||
<h4 style="margin-top: 0;">(Send this to your server's administrator so they can add your key to the server.)</h4>
|
||||
<h1 id="hash" style="user-select: all;">NULL</h1>
|
||||
<h2 style="margin-bottom: 0;">Your Stream Key:</h2>
|
||||
<h4 style="margin-top: 0;">(Keep this in your password manager to authenticate with, <span style='color:red;'>DO NOT SHARE THIS!</span>)</h4>
|
||||
<h1 id="key" style="user-select: all;">NULL</h1>
|
||||
<button style="margin-top: 2em; height: 4em; width: 10em;">Generate Key</button>
|
||||
</body>
|
||||
<footer>
|
||||
<script type="module">
|
||||
import bcrypt from '/lib/bcrypt.js';
|
||||
|
||||
function displayKey(){
|
||||
//Gen a new key
|
||||
let key = genKey();
|
||||
//Display that shit
|
||||
document.querySelector('#key').innerText = key;
|
||||
//Display hash
|
||||
document.querySelector('#hash').innerText = hashKey(key);
|
||||
}
|
||||
|
||||
function genKey(){
|
||||
//Number of chars to generate
|
||||
let keyLength = 25;
|
||||
//Generate a set of cryptographically secure random numbers to derive a stream key from
|
||||
let rnum = crypto.getRandomValues(new Uint8Array(keyLength));
|
||||
//Make a string to hold the key
|
||||
let key = '';
|
||||
|
||||
//For each random digit
|
||||
rnum.forEach((num) => {
|
||||
//We cant use the entire ascii table since most of those chars aren't URL safe
|
||||
//Instead we forst adjust the number to fit between the range of 0-77, then map parts of said range to the ascii table
|
||||
//to generate a url-safe and crpytographically secure stream key
|
||||
let adjustedNum = Math.round(((num * 87) / 255));
|
||||
|
||||
//If we pulled a 9
|
||||
if(adjustedNum <= 9){
|
||||
//Adjust number to proper ascii range for 0-9 and convert to char
|
||||
key += String.fromCharCode(adjustedNum + 48);
|
||||
//If we pulled between a 10 and 35
|
||||
}else if(adjustedNum >= 10 && adjustedNum <= 35){
|
||||
//Adjust number to proper ascii range for A-Z and convert to char
|
||||
key += String.fromCharCode((adjustedNum - 10) + 65);
|
||||
//If we pulled between a 36 and 61
|
||||
}else if(adjustedNum >= 36 && adjustedNum <= 61){
|
||||
//Adjust number to proper ascii range for A-Z and convert to char
|
||||
key += String.fromCharCode((adjustedNum - 36) + 97);
|
||||
//If we pulled between a 61 and 66 (weighted to ensure occurance)
|
||||
}else if(adjustedNum >= 61 && adjustedNum <= 66){
|
||||
//Add a dash
|
||||
key += '-';
|
||||
//If we pulled between a 67 and 72 (weighted to ensure occurance)
|
||||
}else if(adjustedNum >= 67 && adjustedNum <= 72){
|
||||
//Add a period
|
||||
key += '.';
|
||||
//If we pulled between a 73 and 78 (weighted to ensure occurance)
|
||||
}else if(adjustedNum >= 73 && adjustedNum <= 78){
|
||||
//Add an underscore
|
||||
key += '_';
|
||||
//If we pulled between a 79 and 84 (weighted to ensure occurance)
|
||||
}else if(adjustedNum >= 79 && adjustedNum <= 84){
|
||||
//Add a tilde
|
||||
key += '~';
|
||||
}
|
||||
});
|
||||
|
||||
//return our key
|
||||
return key;
|
||||
}
|
||||
|
||||
function hashKey(key){
|
||||
return bcrypt.hashSync(key, 10);
|
||||
}
|
||||
|
||||
//Display a new key on refresh
|
||||
displayKey();
|
||||
|
||||
//Make the button do the thing
|
||||
document.querySelector('button').addEventListener('click', displayKey);
|
||||
</script>
|
||||
</footer>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue