datatype

package
v0.0.0-...-011cc8f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLength

func AddLength(data []byte) []byte

在发送的数据前面加上长度

func AuthDigest

func AuthDigest(s string) string

*

*生成登陆hash
*参考代码:https://gist.github.com/toqueteos/5372776

func CutBytes

func CutBytes(bt *[]byte, length int) *[]byte

剪切[]byte

func DoZlibCompress

func DoZlibCompress(src []byte) []byte

进行zlib压缩

func DoZlibUnCompress

func DoZlibUnCompress(compressSrc []byte) []byte

进行zlib解压缩

func NewCFB8Decrypter

func NewCFB8Decrypter(block cipher.Block, iv []byte) cipher.Stream

func NewCFB8Encrypter

func NewCFB8Encrypter(block cipher.Block, iv []byte) cipher.Stream

func Num2Bytes

func Num2Bytes(num interface{}) ([]byte, bool)

数字转大端字节流

func Num2String

func Num2String(num interface{}) (string, bool)

数字转字符串

func RandByte

func RandByte(n int) string

随机生成对称加密ase密钥

func RsaEncrypt

func RsaEncrypt(publicKey []byte, orignData []byte) ([]byte, bool)

使用服务器发的公钥进行rsa加密

func SessionRequest

func SessionRequest(param string) (string, bool)

向mojong发送session

func TokenRequest

func TokenRequest(apiType string, param string) (string, bool)

向mojong获取验证刷新token等操作

Types

type Bool

type Bool struct{}

func (*Bool) Decode

func (*Bool) Decode(bs *bytes.Buffer) bool

func (*Bool) Encode

func (*Bool) Encode(b bool, bs *bytes.Buffer)

type Cfb8

type Cfb8 struct {
	// contains filtered or unexported fields
}

func (*Cfb8) XORKeyStream

func (x *Cfb8) XORKeyStream(dst, src []byte)

type Double

type Double struct {
}
var DoubleInstance *Double

func (*Double) DecodeByte

func (*Double) DecodeByte(bs *[]byte) float64

func (*Double) Encode

func (*Double) Encode(dou float64) []byte

type Float

type Float struct {
}
var FloatInstance *Float

func (*Float) DecodeByte

func (*Float) DecodeByte(bs *[]byte) float32

func (*Float) Encode

func (*Float) Encode(dou float32) []byte

type Packet

type Packet struct {
	Id     int
	Length int
	Data   *[]byte
}

func (*Packet) GetId

func (p *Packet) GetId()

func (*Packet) GetLength

func (p *Packet) GetLength()

type Player

type Player struct {
	Username     string
	Account      string
	Password     string
	UUID         string
	AccessToken  string
	ClientToken  string
	Id_          string
	SharedSecret string
}

func (*Player) GetToken

func (pl *Player) GetToken() bool

func (*Player) Invalidate

func (pl *Player) Invalidate() bool

func (*Player) SetSession

func (pl *Player) SetSession(serverId string) bool

func (*Player) Signout

func (pl *Player) Signout() bool

type String

type String struct{}
var StringInstance *String

func (*String) Decode

func (*String) Decode(bs *bytes.Buffer) string

* 分成2组,第一组为字符串长度 * 第二组为字符串字节序列

func (*String) Encode

func (*String) Encode(Str string, bs *bytes.Buffer)

* Go中字符串默认Utf-8 * 获取字节序列只需 []byte(Str) * 写入字符串需要先写入字符串的长度

type UnsignedShort

type UnsignedShort struct{}

UnsignedShort是常规的16位2byte无符号整形

var UnsignedShortInstance *UnsignedShort

func (*UnsignedShort) Decode

func (*UnsignedShort) Decode(bs *bytes.Buffer) uint16

func (*UnsignedShort) Encode

func (*UnsignedShort) Encode(us uint16, bs *bytes.Buffer) bool

type VarInt

type VarInt struct{}

VarInt是MC中的协议通信数据类型,最多5位

var VarIntInstance *VarInt

func (*VarInt) Decode

func (*VarInt) Decode(bs *bytes.Buffer) int

func (*VarInt) DecodeByte

func (*VarInt) DecodeByte(bs *[]byte) int

func (*VarInt) Encode

func (v *VarInt) Encode(b int, bs *bytes.Buffer)

func (*VarInt) Encode_

func (*VarInt) Encode_(b int) []byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL