Пример #1
0
func NewTimedRC4Rand() TimedRC4Rand {
	ciph, err := rc4.NewCipher(bytes.Int64ToBytes(time.Nanoseconds()))
	if err != nil {
		panic("rc4 gen error")
	}
	return TimedRC4Rand{ciph}
}
Пример #2
0
func (id Id) Mask() Id {
	sha := sha1.New()
	b := bytes.Int64ToBytes(int64(uint64(id)))
	sha.Write(b)
	sum := sha.Sum()
	i, err := bytes.BytesToInt64(sum[0 : 64/8])
	if err != nil {
		panic("id, mask")
	}
	return Id(uint64(i))
}