Added strong user ID generation that works in tor browser

This commit is contained in:
Kevin F 2022-11-22 03:42:20 +00:00
parent 948aef47c1
commit 59ea100c08
2 changed files with 9 additions and 2 deletions

View File

@ -100,7 +100,7 @@ __ __ _____ __ __ _____
<input type="password" v-model="userIDInput" placeholder="Enter your account ID" required> <input type="password" v-model="userIDInput" placeholder="Enter your account ID" required>
<button @submit.prevent="onSubmit" @click="userID = userIDInput; userLogin()">Login</button> <button @submit.prevent="onSubmit" @click="userID = userIDInput; userLogin()">Login</button>
<button @submit.prevent="onSubmit" @click="userID = (crypto.randomUUID().substring(6) + crypto.randomUUID().substring(30)).replaceAll('-',''); userLogin()">Generate Account</button> <button @submit.prevent="onSubmit" @click="userID = randomID(); userLogin()">Generate Account</button>
</form> </form>
</div> </div>
<br><br> <br><br>

View File

@ -3,7 +3,14 @@ const { createApp } = Vue
let app = createApp({ let app = createApp({
computed: { computed: {
crypto: () => window.crypto, randomID: () => {
let buf2hex = function(buffer) { // buffer is an ArrayBuffer
return [...new Uint8Array(buffer)]
.map(x => x.toString(16).padStart(2, '0'))
.join('');
}
return buf2hex(window.crypto.getRandomValues(new Uint8Array(25)))
},
onLine: () => window.navigator.onLine onLine: () => window.navigator.onLine
}, },
data() { data() {