本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
312B

  1. package ber
  2. func encodeUnsignedInteger(i uint64) []byte {
  3. n := uint64Length(i)
  4. out := make([]byte, n)
  5. var j int
  6. for ; n > 0; n-- {
  7. out[j] = (byte(i >> uint((n-1)*8)))
  8. j++
  9. }
  10. return out
  11. }
  12. func uint64Length(i uint64) (numBytes int) {
  13. numBytes = 1
  14. for i > 255 {
  15. numBytes++
  16. i >>= 8
  17. }
  18. return
  19. }
上海开阖软件有限公司 沪ICP备12045867号-1