示例#1
0
文件: utils.go 项目: bfix/sid
/*
 * 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
}
示例#2
0
文件: utils.go 项目: bfix/sid
/*
 * 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
}
示例#3
0
文件: images.go 项目: bfix/sid_custom
/*
 * Get next (random) image from repository
 * @return *ImageRef - reference to (random) image
 */
func GetNextImage() *ImageRef {
	return imgList[crypto.RandInt(0, len(imgList)-1)]
}