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:
@@ -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])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user