Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Replace (+, /) with (-, _)
- import java.nio.ByteBuffer;
- import java.util.Base64;
- import java.util.UUID;
- class UUID22 {
- public static void main(String[] args) {
- UUID uuid= UUID.randomUUID();
- byte[] src = ByteBuffer.wrap(new byte[16])
- .putLong(uuid.getMostSignificantBits())
- .putLong(uuid.getLeastSignificantBits())
- .array();
- String encoded = Base64.getEncoder().encodeToString(src).substring(0,22).replaceAll("\\+","-").replaceAll("/","_");
- System.out.println(encoded);
- }
- }
Add Comment
Please, Sign In to add comment