I don't understand why this is marked duplicate when clearly the "duplicate" question referred here doesn't ask the same question - though an answer down below contains this information. In any case, the answer I was looking for is below, incase if it helps anyone else.

private String generateSafeToken() {
    SecureRandom random = new SecureRandom();
    byte bytes[] = new byte[20];
    random.nextBytes(bytes);
    Encoder encoder = Base64.getUrlEncoder().withoutPadding();
    String token = encoder.encodeToString(bytes);
    return token;
}
Answer from kovac on Stack Overflow
๐ŸŒ
Jam
jam.dev โ€บ utilities โ€บ random-string-generator
Random String Generator | Free, Open Source & Ad-free
Generate cryptographically secure random strings instantly with this free online random string generator.
๐ŸŒ
Userback
userback.io โ€บ tools โ€บ random-string-generator
Random String Generator - Secure Password & API Key Generator | Userback
January 18, 2026 - Enter the desired length of your random string and select a character set (alphanumeric, password, URL-safe, or custom). Choose how many strings to generate and click Generate. The tool will create cryptographically secure random strings instantly.
People also ask

How many random strings can I generate at once?
You can generate up to 100 strings at once, each with a maximum length of 1,000 characters. You can also choose a custom separator and output format (single line or multiple lines).
๐ŸŒ
mate.tools
mate.tools โ€บ home โ€บ randomness โ€บ random string generator
Random string generator | Generate Secure Random Strings | Mate.tools
Can I use randomly generated strings as passwords?
Yes, the tool uses cryptographically secure random number generation. For strong passwords, select all character sets (uppercase, lowercase, numbers, and symbols) and use a length of at least 16 characters.
๐ŸŒ
mate.tools
mate.tools โ€บ home โ€บ randomness โ€บ random string generator
Random string generator | Generate Secure Random Strings | Mate.tools
Can I generate strings using only specific characters?
Yes, switch to the "Custom characters" mode and enter exactly the characters you want to use. The generator will only use those characters to build the random strings.
๐ŸŒ
mate.tools
mate.tools โ€บ home โ€บ randomness โ€บ random string generator
Random string generator | Generate Secure Random Strings | Mate.tools
๐ŸŒ
RANDOM.ORG
random.org โ€บ strings
RANDOM.ORG - String Generator
This page allows you to generate random text strings using true randomness, which for many purposes is better than the pseudo-random number algorithms typically used in computer programs.
๐ŸŒ
Netlify
randomstringgenerator.netlify.app
Secure Random String Generator | Create Cryptographic Strings
Our generator creates cryptographically secure strings that are: Unpredictable: Cannot be guessed even with knowledge of previous outputs ยท Uniformly distributed: Each character has equal probability of appearing ... 1. Create a typed array for random values const randomValues = new Uint32Array(length); 2.
๐ŸŒ
Orbit2x
orbit2x.com โ€บ random-string
Random String Generator - Create Secure Passwords & Tokens | Orbit2x
Free cryptographically secure random string generator for passwords, API tokens, and keys. Generate custom length strings (1-1000 chars) with uppercase, lowercase, numbers, and symbols. Bulk generation up to 1,000 strings with strength meter.
๐ŸŒ
Mate
mate.tools โ€บ home โ€บ randomness โ€บ random string generator
Random string generator | Generate Secure Random Strings | Mate.tools
Create random strings with customizable characters and lengths for secure passwords, unique IDs, or testing data. Select from letters, numbers, and special char
Find elsewhere
๐ŸŒ
RandomKeygen
randomkeygen.com โ€บ random-string
Random String Generator - Generate Secure Random Strings | RandomKeygen
Free random string generator. Create cryptographically secure random strings with custom length, character sets (alphanumeric, hex, base64), and formats.
๐ŸŒ
Peasy Safe
peasysafe.com โ€บ privacy & security โ€บ random string generator
Random String Generator โ€” Secure Random Token Creator
Generate cryptographically secure random strings, tokens, and IDs. Customizable length and character sets. Web Crypto API.
๐ŸŒ
Generate Random
generate-random.org โ€บ home โ€บ strings
Random String Generator | Generate Random Strings Online Free | Special Characters
3 days ago - This CSPRNG string generator uses cryptographically secure random generation for maximum security. Generate strings for API keys, secure passwords, test data, and unique identifiers.
๐ŸŒ
PineTools
pinetools.com โ€บ random-string-generator
Online Random string generator
Keywords: random strings generator generates chars characters letters numbers symbols
๐ŸŒ
UpVPN
upvpn.app โ€บ tools โ€บ random-string-generator
Random String Generator - Generate Secure Random Strings
Generate secure random strings with configurable character sets, length, and security options for passwords, tokens, and unique identifiers
๐ŸŒ
Swapcode
swapcode.ai โ€บ home โ€บ tools โ€บ random string generator
Random String Generator - Create Secure Random Strings
November 20, 2025 - Generate random strings with custom length and character sets. Perfect for passwords, tokens, IDs, and testing. Free, secure, and instant random string generation.
๐ŸŒ
npm
npmjs.com โ€บ package โ€บ secure-random-string
secure-random-string - npm
Generates a secure random string with a given length. Latest version: 1.1.4, last published: a year ago. Start using secure-random-string in your project by running `npm i secure-random-string`. There are 54 other projects in the npm registry ...
      ยป npm install secure-random-string
    
Published ย  Sep 26, 2024
Version ย  1.1.4
Author ย  Simon Santoro
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ secrets.html
secrets โ€” Generate secure random numbers for managing secrets
The secrets module provides functions for generating secure tokens, suitable for applications such as password resets, hard-to-guess URLs, and similar. ... Return a random byte string containing nbytes number of bytes.
๐ŸŒ
Randomwordgenerator
randomwordgenerator.net โ€บ random-string
Random String Generator | Secure Alphanumeric Strings
Generate secure random strings instantly. Customize length, character sets, and output formats with our free random string generator.
๐ŸŒ
Root
therootcompany.com โ€บ blog โ€บ how-to-generate-secure-random-strings
How to generate a secure random string | Root
October 20, 2020 - crypto .randomBytes(16) .toString('base64') .replace(/\+/g, '-') .replace(/\//g, '_') .replace(/=/g, ''); (async function () { var rnd = new Uint8Array(16); await crypto.getRandomValues(rnd); var b64 = [].slice .apply(rnd) .map(function (ch) { return String.fromCharCode(ch); }) .join(''); var secret = btoa(b64) .replace(/\//g, '_') .replace(/\+/g, '-') .replace(/=/g, ''); console.info(secret); })();
๐ŸŒ
Jsgenerator
jsgenerator.com โ€บ home โ€บ tools โ€บ random string generator
Free Random String Generator JavaScript
Free online JavaScript random string generator. Instantly create secure passwords, API tokens, and unique IDs with customizable length (6-256 chars) and character sets.