...

Source file src/github.com/go-asn1-ber/asn1-ber/content_int.go

Documentation: github.com/go-asn1-ber/asn1-ber

     1  package ber
     2  
     3  func encodeUnsignedInteger(i uint64) []byte {
     4  	n := uint64Length(i)
     5  	out := make([]byte, n)
     6  
     7  	var j int
     8  	for ; n > 0; n-- {
     9  		out[j] = byte(i >> uint((n-1)*8))
    10  		j++
    11  	}
    12  
    13  	return out
    14  }
    15  
    16  func uint64Length(i uint64) (numBytes int) {
    17  	numBytes = 1
    18  
    19  	for i > 255 {
    20  		numBytes++
    21  		i >>= 8
    22  	}
    23  
    24  	return
    25  }
    26  

View as plain text