// Converts a byte to a binary byte array, where each byte is 0x0 or 0x1
Converts a byte to a binary byte array, where each byte is 0x0 or 0x1
// Converts a byte to a binary byte array where each byte is 0x0 or 0x1
func ToBinary(b byte, length int) ([]byte, error) {
	if length > 8 || length < 1 {
		return nil, common.ErrUnsupported
	}
	bs := make([]byte, length)
	for i := length - 1; i >= 0; i-- {
		bs[i] = b & 0x1 
		b = b >> 1
	}
	return bs, nil
}
func ToBinary ( b byte , length int ) ( [ ] byte , error ) { if length > 8 || length < 1 { return nil , common . ErrUnsupported } bs := make ( [ ] byte , length ) for i := length - 1 ; i >= 0 ; i -- { bs [ i ] = b & 0x1 b = b >> 1 } return bs , nil }
Converts a byte to a binary byte array, where each byte is 0x0 or 0x1
Converts a byte to a binary byte array where each byte is 0x0 or 0x1
// 每个字节都是0x0或0x1，不是'0' '1'