2017-08-21 09:06:52 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"encoding/binary"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
|
|
|
// IntToHex converts an int64 to a byte array
|
|
|
|
func IntToHex(num int64) []byte {
|
|
|
|
buff := new(bytes.Buffer)
|
|
|
|
err := binary.Write(buff, binary.BigEndian, num)
|
|
|
|
if err != nil {
|
|
|
|
log.Panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return buff.Bytes()
|
|
|
|
}
|
2017-09-07 02:18:12 -05:00
|
|
|
|
|
|
|
// ReverseBytes reverses a byte array
|
|
|
|
func ReverseBytes(data []byte) {
|
|
|
|
for i, j := 0, len(data)-1; i < j; i, j = i+1, j-1 {
|
|
|
|
data[i], data[j] = data[j], data[i]
|
|
|
|
}
|
|
|
|
}
|