Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion apps/files_sharing/src/utils/GeneratePassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,29 @@ export default async function(verbose = false): Promise<string> {

const array = new Uint8Array(10)
const ratio = passwordSet.length / 255
self.crypto.getRandomValues(array)
getRandomValues(array)
let password = ''
for (let i = 0; i < array.length; i++) {
password += passwordSet.charAt(array[i] * ratio)
}
return password
}

/**
* Fills the given array with cryptographically secure random values.
* If the crypto API is not available, it falls back to less secure Math.random().
* Crypto API is available in modern browsers on secure contexts (HTTPS).
*
* @param {Uint8Array} array - The array to fill with random values.
*/
function getRandomValues(array: Uint8Array): void {
if (self?.crypto?.getRandomValues) {
self.crypto.getRandomValues(array)
return
}

let len = array.length
while (len--) {
array[len] = Math.floor(Math.random() * 256)
}
}
4 changes: 2 additions & 2 deletions dist/3467-3467.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/3467-3467.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/5291-5291.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/5291-5291.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-init.js.map

Large diffs are not rendered by default.

Loading