fix tokens characters
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m6s
Build and test backend / Test-backend (pull_request) Successful in 2m0s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 23s

This commit is contained in:
Debucquoy Anthony 2024-03-16 12:29:51 +01:00
parent 0b27d2e8d8
commit 847936b799
Signed by: tonitch
GPG Key ID: A78D6421F083D42E

View File

@ -9,6 +9,7 @@ import ovh.herisson.Clyde.Tables.User;
import java.io.UnsupportedEncodingException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Calendar;
import java.util.Date;
@ -30,13 +31,10 @@ public class TokenService {
new SecureRandom().nextBytes(bytes);
for (int i = 0; i < bytes.length; i++) {
bytes[i] = (byte) (((bytes[i]+256)%256 %95+ 32));
while ((char)bytes[i] == ';'){
bytes[i] = new SecureRandom().generateSeed(1)[0];
}
}
// will never end up in the catch because of the way that SecureRandom.nextBytes is implemented
try {
return new String(bytes,"ISO_8859_1");
return new String(Base64.getEncoder().encode(bytes),"ISO_8859_1");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}