18 lines
515 B
Kotlin
18 lines
515 B
Kotlin
package net.cismon.urlshortener.helper
|
|
|
|
import org.springframework.stereotype.Component
|
|
import org.springframework.util.Base64Utils
|
|
import java.nio.ByteBuffer
|
|
import java.util.*
|
|
|
|
@Component
|
|
class UuidGenerator {
|
|
fun generate() : String {
|
|
val uuid = UUID.randomUUID()
|
|
return Base64Utils.encodeToUrlSafeString(ByteBuffer
|
|
.allocate(16)
|
|
.putLong(uuid.mostSignificantBits)
|
|
.putLong(uuid.leastSignificantBits)
|
|
.array()).trim('=')
|
|
}
|
|
} |