/* * Create a decimal number of given length to be used as an identifier. * @param size int - desired length of identifier * @return string - generated number string */ func CreateId(size int) string { id := string('1' + crypto.RandInt(0, 8)) for len(id) < size { id += string('0' + crypto.RandInt(0, 9)) } return id }
/* * Create a key of given length to be used as an identifier. * The character set is [a-zA-Z0-9] * @param size int - desired length of key * @return string - generated number string */ func CreateKey(size int) string { id := "" for len(id) < size { v := crypto.RandInt(0, 61) if v < 26 { id += string('a' + v) } else if v < 52 { id += string('A' + v - 26) } else { id += string('0' + v - 52) } } return id }
/* * Get next (random) image from repository * @return *ImageRef - reference to (random) image */ func GetNextImage() *ImageRef { return imgList[crypto.RandInt(0, len(imgList)-1)] }