Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed random number generator generating 10000 index issue in ZK encryption. #174

Open
wants to merge 1 commit into
base: 1.1.5.5
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ public ZKCryptoResponseDto zkDecrypt(ZKCryptoRequestDto cryptoRequestDto) {

private int getRandomKeyIndex() {
List<Integer> indexes = dataEncryptKeystoreRepository.getIdsByKeyStatus(ZKCryptoManagerConstants.ACTIVE_STATUS);
int randomNum = ThreadLocalRandom.current().nextInt(0, indexes.size() + 1);
// Remove plus one ( + 1) because 10000 random number is generated
// but in DB we have indexes from 0 - 9999 only.
// So removed + 1
int randomNum = ThreadLocalRandom.current().nextInt(0, indexes.size());
return indexes.get(randomNum);
}

Expand Down