diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2023-01-16 22:26:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-16 22:26:42 +0100 |
commit | 7f81ce55470845239a80ce3c426e29713fc4575c (patch) | |
tree | 5cd5740452edac7dfa466364a62ed886f5c1088d /apps/files_sharing | |
parent | 018a597d9bc73faf2f7d62fcfb562396baa4a1fe (diff) | |
parent | e9f7ea11bb85b599daec7a918764dc39c70e637c (diff) | |
download | nextcloud-server-7f81ce55470845239a80ce3c426e29713fc4575c.tar.gz nextcloud-server-7f81ce55470845239a80ce3c426e29713fc4575c.zip |
Merge pull request #36093 from nextcloud/techdebt/noid/improve-share-pw-generation
Improve password generation for link shares
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/src/utils/GeneratePassword.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/apps/files_sharing/src/utils/GeneratePassword.js b/apps/files_sharing/src/utils/GeneratePassword.js index 6da6076b937..63cc68983a1 100644 --- a/apps/files_sharing/src/utils/GeneratePassword.js +++ b/apps/files_sharing/src/utils/GeneratePassword.js @@ -25,6 +25,7 @@ import Config from '../services/ConfigService' import { showError, showSuccess } from '@nextcloud/dialogs' const config = new Config() +// note: some chars removed on purpose to make them human friendly when read out const passwordSet = 'abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789' /** @@ -49,10 +50,12 @@ export default async function() { } } - // generate password of 10 length based on passwordSet - return Array(10).fill(0) - .reduce((prev, curr) => { - prev += passwordSet.charAt(Math.floor(Math.random() * passwordSet.length)) - return prev - }, '') + const array = new Uint8Array(10) + const ratio = passwordSet.length / 255 + self.crypto.getRandomValues(array) + let password = '' + for (let i = 0; i < array.length; i++) { + password += passwordSet.charAt(array[i] * ratio) + } + return password } |