public static byte [ ] encodeBitString ( int padBits , byte [ ] value ) { checkArgument ( padBits >= 0 && padBits < 8 , "Invalid pad bits" ) ; byte [ ] lengthEncoded = encodeLength ( value . length + 1 ) ; ByteArrayDataOutput out = ByteStreams . newDataOutput ( 2 + lengthEncoded . length + value . length ) ; out . write ( BIT_STRING_TAG ) ; out . write ( lengthEncoded ) ; out . write ( padBits ) ; out . write ( value ) ; return out . toByteArray ( ) ; }
Encodes a bit string padded with the specified number of bits . The encoding is a byte containing the padBits followed by the value bytes .