This is an extension to this question
If the string which is being encoded is guaranteed to be unique, for example, a UUID , does this also mean that the base64 encoded string is also guaranteed to be unique?
If we consider the following Java example,
UUID uuid = UUID.randomUUID();
ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16])
.putLong(uuid.getMostSignificantBits())
.putLong(uuid.getLeastSignificantBits());
String encodedUUID = Base64.getUrlEncoder()
.withoutPadding()
.encodeToString(byteBuffer.array());
Since uuid
is unique, does this imply encodedUUID
will also be unique? If so what are chances of collision in case of a large number of encoded UUIDs?
If the data is unique, it will be unique when base64 encoded.
Base64 encoding is a lossless representation of the encoded data. It's the same data, just represented using different symbols to encode it in a fairly high density, printable way.