Ejemplo n.º 1
0
func (ev *EncryptEvent) Encode(buffer *bytes.Buffer) {
	EncodeUInt64Value(buffer, uint64(ev.EncryptType))
	buf := new(bytes.Buffer)
	EncodeEvent(buf, ev.Ev)
	switch ev.EncryptType {
	case ENCRYPTER_NONE:
		buffer.Write(buf.Bytes())
	case ENCRYPTER_SE1:
		newbuf := util.SimpleEncrypt(buf)
		buffer.Write(newbuf.Bytes())
		newbuf.Reset()
	}
	buf.Reset()
}
Ejemplo n.º 2
0
func (ev *EncryptEvent) Encode(buffer *bytes.Buffer) {
	EncodeUInt64Value(buffer, uint64(ev.EncryptType))
	buf := new(bytes.Buffer)
	EncodeEvent(buf, ev.Ev)
	switch ev.EncryptType {
	case ENCRYPTER_NONE:
		buffer.Write(buf.Bytes())
	case ENCRYPTER_SE1:
		newbuf := util.SimpleEncrypt(buf)
		buffer.Write(newbuf.Bytes())
		newbuf.Reset()
	case ENCRYPTER_RC4:
		dst := make([]byte, buf.Len())
		cipher, _ := rc4.NewCipher([]byte(rc4Key))
		cipher.XORKeyStream(dst, buf.Bytes())
		buffer.Write(dst)
	}
	buf.Reset()
}