2018-03-02 15:24:09 +00:00
|
|
|
package util
|
|
|
|
|
|
|
|
// ArrayReverse return a reversed version of the given byte slice.
|
|
|
|
func ArrayReverse(b []byte) []byte {
|
|
|
|
// Protect from big.Ints that have 1 len bytes.
|
|
|
|
if len(b) < 2 {
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
dest := make([]byte, len(b))
|
2019-02-05 12:22:10 +00:00
|
|
|
for i, j := 0, len(b)-1; i <= j; i, j = i+1, j-1 {
|
2018-03-02 15:24:09 +00:00
|
|
|
dest[i], dest[j] = b[j], b[i]
|
|
|
|
}
|
|
|
|
return dest
|
|
|
|
}
|