You most likely used Base64 encoding. It’s about encoding any sequence of data as a printable string (digits, lower case and upper case letters). But Base64 has variations. E.g., not every Base64 variant allows safe transfer of any data as URL parameters. For that purpose there is a special dialect of Base64: Url-safe encoding.
Base64.Encoder encoder = java.util.Base64.getUrlEncoder().withoutPadding(); String base64String = encoder.encodeToString(byteArray);