public static int encodeInteger ( int value , ByteBuffer buf ) { int pos = buf . position ( ) ; int contentLength = 0 ; do { pos -- ; buf . put ( pos , ( byte ) ( value & 0xff ) ) ; value >>>= 8 ; contentLength ++ ; } while ( value != 0 ) ; buf . position ( buf . position ( ) - contentLength ) ; int headerLen = DerUtils . encodeIdAndLength ( DerId . TagClass . UNIVERSAL , DerId . EncodingType . PRIMITIVE , ASN1_INTEGER_TAG_NUM , contentLength , buf ) ; return headerLen + contentLength ; }
Encode an ASN . 1 INTEGER .