001package com.nimbusds.jose.util;
002
003
004/**
005 * Integer utilities.
006 *
007 * @author Vladimir Dzhuvinov
008 * @version 2015-05-12
009 */
010public class IntegerUtils {
011
012
013        /**
014         * Returns a four byte array representation of the specified integer.
015         *
016         * @param intValue The integer to be converted.
017         *
018         * @return The byte array representation of the integer.
019         */
020        public static byte[] toBytes(int intValue) {
021
022                byte[] res = new byte[4];
023                res[0] = (byte) (intValue >>> 24);
024                res[1] = (byte) ((intValue >>> 16) & 0xFF);
025                res[2] = (byte) ((intValue >>> 8) & 0xFF);
026                res[3] = (byte) (intValue & 0xFF);
027                return res;
028        }
029
030
031        /**
032         * Prevents public instantiation.
033         */
034        private IntegerUtils() {
035
036        }
037}