Pack (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.util

## Class Pack

- java.lang.Object
- - org.bouncycastle.util.Pack

-     public abstract class Pack
      extends java.lang.Object

  Utility methods for converting byte arrays into ints and longs, and back again.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Pack()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `bigEndianToInt_High(byte[] bs, int off, int len)`
    `static int` | `bigEndianToInt_Low(byte[] bs, int off, int len)`
    `static int` | `bigEndianToInt(byte[] bs, int off)`
    `static void` | `bigEndianToInt(byte[] bs, int off, int[] ns)`
    `static void` | `bigEndianToInt(byte[] bs, int off, int[] ns, int nsOff, int nsLen)`
    `static long` | `bigEndianToLong_High(byte[] bs, int off, int len)`
    `static long` | `bigEndianToLong_Low(byte[] bs, int off, int len)`
    `static long` | `bigEndianToLong(byte[] bs, int off)`
    `static void` | `bigEndianToLong(byte[] bs, int off, long[] ns)`
    `static void` | `bigEndianToLong(byte[] bs, int bsOff, long[] ns, int nsOff, int nsLen)`
    `static short` | `bigEndianToShort(byte[] bs, int off)`
    `static void` | `intToBigEndian_High(int n, byte[] bs, int off, int len)`
    `static void` | `intToBigEndian_Low(int n, byte[] bs, int off, int len)`
    `static byte[]` | `intToBigEndian(int n)`
    `static byte[]` | `intToBigEndian(int[] ns)`
    `static void` | `intToBigEndian(int[] ns, byte[] bs, int off)`
    `static void` | `intToBigEndian(int[] ns, int nsOff, int nsLen, byte[] bs, int bsOff)`
    `static void` | `intToBigEndian(int n, byte[] bs)`
    `static void` | `intToBigEndian(int n, byte[] bs, int off)`
    `static void` | `intToLittleEndian_High(int n, byte[] bs, int off, int len)`
    `static void` | `intToLittleEndian_Low(int n, byte[] bs, int off, int len)`
    `static byte[]` | `intToLittleEndian(int n)`
    `static byte[]` | `intToLittleEndian(int[] ns)`
    `static void` | `intToLittleEndian(int[] ns, byte[] bs, int off)`
    `static void` | `intToLittleEndian(int[] ns, int nsOff, int nsLen, byte[] bs, int bsOff)`
    `static void` | `intToLittleEndian(int n, byte[] bs, int off)`
    `static int` | `littleEndianToInt_High(byte[] bs, int off, int len)`
    `static int` | `littleEndianToInt_Low(byte[] bs, int off, int len)`
    `static int` | `littleEndianToInt(byte[] bs, int off)`
    `static int[]` | `littleEndianToInt(byte[] bs, int off, int count)`
    `static void` | `littleEndianToInt(byte[] bs, int off, int[] ns)`
    `static void` | `littleEndianToInt(byte[] bs, int bOff, int[] ns, int nOff, int count)`
    `static int` | `littleEndianToInt24(byte[] bs, int off)`
    `static long` | `littleEndianToLong_High(byte[] bs, int off, int len)`
    `static long` | `littleEndianToLong_Low(byte[] bs, int off, int len)`
    `static long` | `littleEndianToLong(byte[] bs, int off)`
    `static long[]` | `littleEndianToLong(byte[] bs, int off, int count)`
    `static void` | `littleEndianToLong(byte[] bs, int off, long[] ns)`
    `static void` | `littleEndianToLong(byte[] bs, int bsOff, long[] ns, int nsOff, int nsLen)`
    `static short` | `littleEndianToShort(byte[] bs, int off)`
    `static short[]` | `littleEndianToShort(byte[] bs, int off, int count)`
    `static void` | `littleEndianToShort(byte[] bs, int bOff, short[] ns)`
    `static void` | `littleEndianToShort(byte[] bs, int bOff, short[] ns, int nOff, int count)`
    `static void` | `longToBigEndian_High(long n, byte[] bs, int off, int len)`
    `static void` | `longToBigEndian_Low(long n, byte[] bs, int off, int len)`
    `static byte[]` | `longToBigEndian(long n)`
    `static byte[]` | `longToBigEndian(long[] ns)`
    `static void` | `longToBigEndian(long[] ns, byte[] bs, int off)`
    `static void` | `longToBigEndian(long[] ns, int nsOff, int nsLen, byte[] bs, int bsOff)`
    `static void` | `longToBigEndian(long n, byte[] bs, int off)`
    `static void` | `longToLittleEndian_High(long n, byte[] bs, int off, int len)`
    `static void` | `longToLittleEndian_Low(long n, byte[] bs, int off, int len)`
    `static byte[]` | `longToLittleEndian(long n)`
    `static byte[]` | `longToLittleEndian(long[] ns)`
    `static void` | `longToLittleEndian(long[] ns, byte[] bs, int off)`
    `static void` | `longToLittleEndian(long[] ns, int nsOff, int nsLen, byte[] bs, int bsOff)`
    `static void` | `longToLittleEndian(long n, byte[] bs, int off)`
    `static byte[]` | `shortToBigEndian(short n)`
    `static void` | `shortToBigEndian(short n, byte[] bs, int off)`
    `static byte[]` | `shortToLittleEndian(short n)`
    `static byte[]` | `shortToLittleEndian(short[] ns)`
    `static void` | `shortToLittleEndian(short[] ns, byte[] bs, int bsOff)`
    `static void` | `shortToLittleEndian(short[] ns, int nsOff, int nsLen, byte[] bs, int bsOff)`
    `static void` | `shortToLittleEndian(short n, byte[] bs, int off)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Pack

          public Pack()

  - ### Method Detail

    - #### bigEndianToShort

          public static short bigEndianToShort(byte[] bs,
                                               int off)

    - #### bigEndianToInt

          public static int bigEndianToInt(byte[] bs,
                                           int off)

    - #### bigEndianToInt

          public static void bigEndianToInt(byte[] bs,
                                            int off,
                                            int[] ns)

    - #### bigEndianToInt

          public static void bigEndianToInt(byte[] bs,
                                            int off,
                                            int[] ns,
                                            int nsOff,
                                            int nsLen)

    - #### bigEndianToInt_High

          public static int bigEndianToInt_High(byte[] bs,
                                                int off,
                                                int len)

    - #### bigEndianToInt_Low

          public static int bigEndianToInt_Low(byte[] bs,
                                               int off,
                                               int len)

    - #### intToBigEndian

          public static byte[] intToBigEndian(int n)

    - #### intToBigEndian

          public static void intToBigEndian(int n,
                                            byte[] bs)

    - #### intToBigEndian

          public static void intToBigEndian(int n,
                                            byte[] bs,
                                            int off)

    - #### intToBigEndian

          public static byte[] intToBigEndian(int[] ns)

    - #### intToBigEndian

          public static void intToBigEndian(int[] ns,
                                            byte[] bs,
                                            int off)

    - #### intToBigEndian

          public static void intToBigEndian(int[] ns,
                                            int nsOff,
                                            int nsLen,
                                            byte[] bs,
                                            int bsOff)

    - #### intToBigEndian_High

          public static void intToBigEndian_High(int n,
                                                 byte[] bs,
                                                 int off,
                                                 int len)

    - #### intToBigEndian_Low

          public static void intToBigEndian_Low(int n,
                                                byte[] bs,
                                                int off,
                                                int len)

    - #### bigEndianToLong

          public static long bigEndianToLong(byte[] bs,
                                             int off)

    - #### bigEndianToLong

          public static void bigEndianToLong(byte[] bs,
                                             int off,
                                             long[] ns)

    - #### bigEndianToLong

          public static void bigEndianToLong(byte[] bs,
                                             int bsOff,
                                             long[] ns,
                                             int nsOff,
                                             int nsLen)

    - #### bigEndianToLong_High

          public static long bigEndianToLong_High(byte[] bs,
                                                  int off,
                                                  int len)

    - #### bigEndianToLong_Low

          public static long bigEndianToLong_Low(byte[] bs,
                                                 int off,
                                                 int len)

    - #### longToBigEndian

          public static byte[] longToBigEndian(long n)

    - #### longToBigEndian

          public static void longToBigEndian(long n,
                                             byte[] bs,
                                             int off)

    - #### longToBigEndian

          public static byte[] longToBigEndian(long[] ns)

    - #### longToBigEndian

          public static void longToBigEndian(long[] ns,
                                             byte[] bs,
                                             int off)

    - #### longToBigEndian

          public static void longToBigEndian(long[] ns,
                                             int nsOff,
                                             int nsLen,
                                             byte[] bs,
                                             int bsOff)

    - #### longToBigEndian_High

          public static void longToBigEndian_High(long n,
                                                  byte[] bs,
                                                  int off,
                                                  int len)

    - #### longToBigEndian_Low

          public static void longToBigEndian_Low(long n,
                                                 byte[] bs,
                                                 int off,
                                                 int len)

    - #### littleEndianToShort

          public static short littleEndianToShort(byte[] bs,
                                                  int off)

    - #### littleEndianToShort

          public static void littleEndianToShort(byte[] bs,
                                                 int bOff,
                                                 short[] ns)

    - #### littleEndianToShort

          public static void littleEndianToShort(byte[] bs,
                                                 int bOff,
                                                 short[] ns,
                                                 int nOff,
                                                 int count)

    - #### littleEndianToShort

          public static short[] littleEndianToShort(byte[] bs,
                                                    int off,
                                                    int count)

    - #### littleEndianToInt24

          public static int littleEndianToInt24(byte[] bs,
                                                int off)

    - #### littleEndianToInt

          public static int littleEndianToInt(byte[] bs,
                                              int off)

    - #### littleEndianToInt_High

          public static int littleEndianToInt_High(byte[] bs,
                                                   int off,
                                                   int len)

    - #### littleEndianToInt_Low

          public static int littleEndianToInt_Low(byte[] bs,
                                                  int off,
                                                  int len)

    - #### littleEndianToInt

          public static void littleEndianToInt(byte[] bs,
                                               int off,
                                               int[] ns)

    - #### littleEndianToInt

          public static void littleEndianToInt(byte[] bs,
                                               int bOff,
                                               int[] ns,
                                               int nOff,
                                               int count)

    - #### littleEndianToInt

          public static int[] littleEndianToInt(byte[] bs,
                                                int off,
                                                int count)

    - #### shortToLittleEndian

          public static byte[] shortToLittleEndian(short n)

    - #### shortToLittleEndian

          public static void shortToLittleEndian(short n,
                                                 byte[] bs,
                                                 int off)

    - #### shortToLittleEndian

          public static void shortToLittleEndian(short[] ns,
                                                 byte[] bs,
                                                 int bsOff)

    - #### shortToLittleEndian

          public static void shortToLittleEndian(short[] ns,
                                                 int nsOff,
                                                 int nsLen,
                                                 byte[] bs,
                                                 int bsOff)

    - #### shortToLittleEndian

          public static byte[] shortToLittleEndian(short[] ns)

    - #### shortToBigEndian

          public static byte[] shortToBigEndian(short n)

    - #### shortToBigEndian

          public static void shortToBigEndian(short n,
                                              byte[] bs,
                                              int off)

    - #### intToLittleEndian

          public static byte[] intToLittleEndian(int n)

    - #### intToLittleEndian

          public static void intToLittleEndian(int n,
                                               byte[] bs,
                                               int off)

    - #### intToLittleEndian

          public static byte[] intToLittleEndian(int[] ns)

    - #### intToLittleEndian

          public static void intToLittleEndian(int[] ns,
                                               byte[] bs,
                                               int off)

    - #### intToLittleEndian

          public static void intToLittleEndian(int[] ns,
                                               int nsOff,
                                               int nsLen,
                                               byte[] bs,
                                               int bsOff)

    - #### intToLittleEndian_High

          public static void intToLittleEndian_High(int n,
                                                    byte[] bs,
                                                    int off,
                                                    int len)

    - #### intToLittleEndian_Low

          public static void intToLittleEndian_Low(int n,
                                                   byte[] bs,
                                                   int off,
                                                   int len)

    - #### littleEndianToLong

          public static long littleEndianToLong(byte[] bs,
                                                int off)

    - #### littleEndianToLong

          public static void littleEndianToLong(byte[] bs,
                                                int off,
                                                long[] ns)

    - #### littleEndianToLong

          public static void littleEndianToLong(byte[] bs,
                                                int bsOff,
                                                long[] ns,
                                                int nsOff,
                                                int nsLen)

    - #### littleEndianToLong

          public static long[] littleEndianToLong(byte[] bs,
                                                  int off,
                                                  int count)

    - #### littleEndianToLong_High

          public static long littleEndianToLong_High(byte[] bs,
                                                     int off,
                                                     int len)

    - #### littleEndianToLong_Low

          public static long littleEndianToLong_Low(byte[] bs,
                                                    int off,
                                                    int len)

    - #### longToLittleEndian

          public static byte[] longToLittleEndian(long n)

    - #### longToLittleEndian

          public static void longToLittleEndian(long n,
                                                byte[] bs,
                                                int off)

    - #### longToLittleEndian

          public static byte[] longToLittleEndian(long[] ns)

    - #### longToLittleEndian

          public static void longToLittleEndian(long[] ns,
                                                byte[] bs,
                                                int off)

    - #### longToLittleEndian

          public static void longToLittleEndian(long[] ns,
                                                int nsOff,
                                                int nsLen,
                                                byte[] bs,
                                                int bsOff)

    - #### longToLittleEndian_High

          public static void longToLittleEndian_High(long n,
                                                     byte[] bs,
                                                     int off,
                                                     int len)

    - #### longToLittleEndian_Low

          public static void longToLittleEndian_Low(long n,
                                                    byte[] bs,
                                                    int off,
                                                    int len)