Skip to content

Commit f5c4d26

Browse files
committed
Improved Generate Room ID Algorithm. Minor UI improvements
1 parent 8290118 commit f5c4d26

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ <h2 class="fw-normal" style="margin:0; font-size: calc(1.2rem + 0.3vw)">Send fil
188188
<div class="row">
189189
<div class="col col-1-3"></div>
190190
<div class="col col-2-3">
191-
USERS
191+
Users
192192
<span id="transfer-users-count" style="font-size: 14px"> (0)</span>
193193
</div>
194194
<div class="col col-3-3" style="text-align: right">
@@ -219,7 +219,7 @@ <h2 class="fw-normal" style="margin:0; font-size: calc(1.2rem + 0.3vw)">Send fil
219219
<div class="row">
220220
<div class="col col-1-3"></div>
221221
<div class="col col-2-3">
222-
FILES
222+
Files
223223
<span id="transfer-files-count" style="font-size: 14px"> (0)</span>
224224
</div>
225225
<div class="col col-3-3" style="text-align: right">
@@ -411,7 +411,7 @@ <h5 style="color: var(--color-h1); margin:0">
411411

412412
<!-- FOOTER -->
413413
<div id="footer" class="mx-auto pt-4 text-md-center">
414-
<p class="fw-normal" style="font-size:14px; margin:0;">This platform uses end-to-end encryption to ensure your data is protected from unauthorized access, and only authorized users can access the content.</p>
414+
<p class="fw-normal" style="font-size:14px; margin:0;">This platform uses end-to-end encryption to ensure your data is protected from unauthorized access.</p>
415415
</div>
416416
</div>
417417
</div>

src/js/script.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,14 @@ function parseBytes(bytes) {
298298

299299
// Function to generate a random string in the format XXX-XXXX-XXX.
300300
function generateRoomID() {
301-
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
302-
const generateRandomString = (length) => Array.from({length}, () => characters.charAt(Math.floor(Math.random() * characters.length))).join('');
303-
return [3, 4, 3].map(length => generateRandomString(length)).join('-');
301+
const length = 10
302+
const alphabet = 'abcdefghijklmnopqrstuvwxyz';
303+
const random = crypto.getRandomValues(new Uint8Array(length));
304+
let room_id = "";
305+
for (let i = 0; i < length; i++) {
306+
room_id += alphabet[alphabet.length & random[i]];
307+
}
308+
return `${room_id.slice(0, 3)}-${room_id.slice(3, 7)}-${room_id.slice(7, 10)}`;
304309
}
305310

306311
// On document loaded, execute onLoad() method.

0 commit comments

Comments
 (0)