Here you can find the source of intToASN1(byte[] d, int idx, int val)
Parameter | Description |
---|---|
val | 0-65535 |
public static int intToASN1(byte[] d, int idx, int val)
//package com.java2s; //License from project: Open Source License public class Main { /**//ww w . j ava2 s . c o m * Output an length or integer value in ASN.1 * Does NOT output the tag e.g. 0x02 / 0x30 * * @param val 0-65535 * @return the new index * @since 0.9.25 */ public static int intToASN1(byte[] d, int idx, int val) { if (val < 0 || val > 65535) throw new IllegalArgumentException("fixme length " + val); if (val > 127) { if (val > 255) { d[idx++] = (byte) 0x82; d[idx++] = (byte) (val >> 8); } else { d[idx++] = (byte) 0x81; } } d[idx++] = (byte) val; return idx; } }