padLeft pads a byte slice with zeros on the left such that its length is n. If the slice is already longer than n, it is returned as is.
(b []byte, n int)
| 184 | // padLeft pads a byte slice with zeros on the left such that its length is n. |
| 185 | // If the slice is already longer than n, it is returned as is. |
| 186 | func padLeft(b []byte, n int) []byte { |
| 187 | if len(b) >= n { |
| 188 | return b |
| 189 | } |
| 190 | |
| 191 | padded := make([]byte, n) |
| 192 | copy(padded[n-len(b):], b) |
| 193 | return padded |
| 194 | } |