1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-03 07:45:29 -05:00

refactor bytes functions

This commit is contained in:
v2ray
2016-06-26 22:34:48 +02:00
parent d12d5b0593
commit 67ac925ee7
16 changed files with 78 additions and 64 deletions

View File

@@ -10,24 +10,24 @@ func ByteToHexString(value byte) string {
}
func BytesToUint16(value []byte) uint16 {
return uint16(value[0])<<8 + uint16(value[1])
return uint16(value[0])<<8 | uint16(value[1])
}
func BytesToUint32(value []byte) uint32 {
return uint32(value[0])<<24 +
uint32(value[1])<<16 +
uint32(value[2])<<8 +
return uint32(value[0])<<24 |
uint32(value[1])<<16 |
uint32(value[2])<<8 |
uint32(value[3])
}
func BytesToInt64(value []byte) int64 {
return int64(value[0])<<56 +
int64(value[1])<<48 +
int64(value[2])<<40 +
int64(value[3])<<32 +
int64(value[4])<<24 +
int64(value[5])<<16 +
int64(value[6])<<8 +
return int64(value[0])<<56 |
int64(value[1])<<48 |
int64(value[2])<<40 |
int64(value[3])<<32 |
int64(value[4])<<24 |
int64(value[5])<<16 |
int64(value[6])<<8 |
int64(value[7])
}