Skip to content
Zachary Whitley edited this page Sep 14, 2020 · 9 revisions

Welcome to the stardog-extensions wiki!

import java.security.SecureRandom;
import java.util.Base64;

public class SecureRandomString {
    private static final SecureRandom random = new SecureRandom();
    private static final Base64.Encoder encoder = Base64.getUrlEncoder().withoutPadding();

    public static String generate() {
        byte[] buffer = new byte[20];
        random.nextBytes(buffer);
        return encoder.encodeToString(buffer);
    }
}
``

- https://github.com/aventrix/jnanoid
Clone this wiki locally