Example #1
0
func randCryptoCtx() event.CryptoContext {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	tmp := uint64(r.Int63())
	var ctx event.CryptoContext
	ctx.EncryptIV = tmp
	ctx.DecryptIV = tmp
	ctx.Method = event.GetDefaultCryptoMethod()
	return ctx
}
Example #2
0
func NewAuthEvent(secureTransport bool) *event.AuthEvent {
	auth := &event.AuthEvent{}
	auth.User = GConf.Auth
	//auth.Mac = getDeviceId()
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	auth.SetId(uint32(r.Int31()))
	auth.Rand = []byte(helper.RandAsciiString(int(r.Int31n(128))))
	if secureTransport && strings.EqualFold(GConf.Encrypt.Method, "auto") {
		auth.EncryptMethod = uint8(event.NoneEncrypter)
	} else {
		auth.EncryptMethod = event.GetDefaultCryptoMethod()
	}
	return auth
}