package tinuURL import ( "crypto/md5" "fmt" "time" "github.com/google/uuid" "github.com/jxskiss/base62" ) // GenerateKey generates a new tiny URL key (string) // by hashing the string (md5) and encoding the hash in base62. // // Example: https://go.dev/play/p/tidujUBZ3sY func GenerateKey(str string, size int) string { hash := md5.Sum([]byte(str)) encodedHash := base62.Encode([]byte(hash[:])) return string(encodedHash[:size]) }