java.lang.Object
org.codelibs.jcifs.smb1.util.Encdec
Encoding and decoding utility class for SMB1 protocol.
Provides methods for encoding/decoding various data types in different byte orders.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longMilliseconds between January 1, 1970 and January 1, 1601 (Windows epoch).static final longSeconds between January 1, 1904 and January 1, 1970 (Mac epoch).static final intTime encoding type: 1601 epoch, 64-bit nanoseconds, big-endian.static final intTime encoding type: 1601 epoch, 64-bit nanoseconds, little-endian.static final intTime encoding type: 1904 epoch, 32-bit seconds, big-endian.static final intTime encoding type: 1904 epoch, 32-bit seconds, little-endian.static final intTime encoding type: 1970 epoch, 64-bit milliseconds, big-endian.static final intTime encoding type: 1970 epoch, 64-bit milliseconds, little-endian.static final intTime encoding type: 1970 epoch, 32-bit seconds, big-endian.static final intTime encoding type: 1970 epoch, 32-bit seconds, little-endian. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubledec_doublebe(byte[] src, int si) Decodes a double value from big-endian byte order.static doubledec_doublele(byte[] src, int si) Decodes a double value from little-endian byte order.static floatdec_floatbe(byte[] src, int si) Decodes a float value from big-endian byte order.static floatdec_floatle(byte[] src, int si) Decodes a float value from little-endian byte order.static Datedec_time(byte[] src, int si, int enc) Decodes a Date value according to the specified time encoding type.static Stringdec_ucs2le(byte[] src, int si, int slim, char[] buf) Decodes a UCS-2 little-endian encoded string from a byte array.static shortdec_uint16be(byte[] src, int si) Decodes a 16-bit unsigned integer from big-endian byte order.static shortdec_uint16le(byte[] src, int si) Decodes a 16-bit unsigned integer from little-endian byte order.static intdec_uint32be(byte[] src, int si) Decodes a 32-bit unsigned integer from big-endian byte order.static intdec_uint32le(byte[] src, int si) Decodes a 32-bit unsigned integer from little-endian byte order.static longdec_uint64be(byte[] src, int si) Decodes a 64-bit unsigned integer from big-endian byte order.static longdec_uint64le(byte[] src, int si) Decodes a 64-bit unsigned integer from little-endian byte order.static Stringdec_utf8(byte[] src, int si, int slim) Decodes a UTF-8 encoded string from a byte array.static intenc_doublebe(double d, byte[] dst, int di) Encodes a double value in big-endian byte order.static intenc_doublele(double d, byte[] dst, int di) Encodes a double value in little-endian byte order.static intenc_floatbe(float f, byte[] dst, int di) Encodes a float value in big-endian byte order.static intenc_floatle(float f, byte[] dst, int di) Encodes a float value in little-endian byte order.static intEncodes a Date value according to the specified time encoding type.static intenc_uint16be(short s, byte[] dst, int di) Encodes a 16-bit unsigned integer in big-endian byte order.static intenc_uint16le(short s, byte[] dst, int di) Encodes a 16-bit unsigned integer in little-endian byte order.static intenc_uint32be(int i, byte[] dst, int di) Encodes a 32-bit unsigned integer in big-endian byte order.static intenc_uint32le(int i, byte[] dst, int di) Encodes a 32-bit unsigned integer in little-endian byte order.static intenc_uint64be(long l, byte[] dst, int di) Encodes a 64-bit unsigned integer in big-endian byte order.static intenc_uint64le(long l, byte[] dst, int di) Encodes a 64-bit unsigned integer in little-endian byte order.static intEncodes a String as UTF-8 bytes.
-
Field Details
-
MILLISECONDS_BETWEEN_1970_AND_1601
public static final long MILLISECONDS_BETWEEN_1970_AND_1601Milliseconds between January 1, 1970 and January 1, 1601 (Windows epoch).- See Also:
-
SEC_BETWEEEN_1904_AND_1970
public static final long SEC_BETWEEEN_1904_AND_1970Seconds between January 1, 1904 and January 1, 1970 (Mac epoch).- See Also:
-
TIME_1970_SEC_32BE
public static final int TIME_1970_SEC_32BETime encoding type: 1970 epoch, 32-bit seconds, big-endian.- See Also:
-
TIME_1970_SEC_32LE
public static final int TIME_1970_SEC_32LETime encoding type: 1970 epoch, 32-bit seconds, little-endian.- See Also:
-
TIME_1904_SEC_32BE
public static final int TIME_1904_SEC_32BETime encoding type: 1904 epoch, 32-bit seconds, big-endian.- See Also:
-
TIME_1904_SEC_32LE
public static final int TIME_1904_SEC_32LETime encoding type: 1904 epoch, 32-bit seconds, little-endian.- See Also:
-
TIME_1601_NANOS_64LE
public static final int TIME_1601_NANOS_64LETime encoding type: 1601 epoch, 64-bit nanoseconds, little-endian.- See Also:
-
TIME_1601_NANOS_64BE
public static final int TIME_1601_NANOS_64BETime encoding type: 1601 epoch, 64-bit nanoseconds, big-endian.- See Also:
-
TIME_1970_MILLIS_64BE
public static final int TIME_1970_MILLIS_64BETime encoding type: 1970 epoch, 64-bit milliseconds, big-endian.- See Also:
-
TIME_1970_MILLIS_64LE
public static final int TIME_1970_MILLIS_64LETime encoding type: 1970 epoch, 64-bit milliseconds, little-endian.- See Also:
-
-
Constructor Details
-
Encdec
public Encdec()Default constructor for Encdec. This is a utility class with static methods.
-
-
Method Details
-
enc_uint16be
public static int enc_uint16be(short s, byte[] dst, int di) Encodes a 16-bit unsigned integer in big-endian byte order.- Parameters:
s- the short value to encodedst- the destination byte arraydi- the starting index in the destination array- Returns:
- the number of bytes written (2)
-
enc_uint32be
public static int enc_uint32be(int i, byte[] dst, int di) Encodes a 32-bit unsigned integer in big-endian byte order.- Parameters:
i- the integer value to encodedst- the destination byte arraydi- the starting index in the destination array- Returns:
- the number of bytes written (4)
-
enc_uint16le
public static int enc_uint16le(short s, byte[] dst, int di) Encodes a 16-bit unsigned integer in little-endian byte order.- Parameters:
s- the short value to encodedst- the destination byte arraydi- the starting index in the destination array- Returns:
- the number of bytes written (2)
-
enc_uint32le
public static int enc_uint32le(int i, byte[] dst, int di) Encodes a 32-bit unsigned integer in little-endian byte order.- Parameters:
i- the integer value to encodedst- the destination byte arraydi- the starting index in the destination array- Returns:
- the number of bytes written (4)
-
dec_uint16be
public static short dec_uint16be(byte[] src, int si) Decodes a 16-bit unsigned integer from big-endian byte order.- Parameters:
src- the source byte arraysi- the starting index in the source array- Returns:
- the decoded short value
-
dec_uint32be
public static int dec_uint32be(byte[] src, int si) Decodes a 32-bit unsigned integer from big-endian byte order.- Parameters:
src- the source byte arraysi- the starting index in the source array- Returns:
- the decoded integer value
-
dec_uint16le
public static short dec_uint16le(byte[] src, int si) Decodes a 16-bit unsigned integer from little-endian byte order.- Parameters:
src- the source byte arraysi- the starting index in the source array- Returns:
- the decoded short value
-
dec_uint32le
public static int dec_uint32le(byte[] src, int si) Decodes a 32-bit unsigned integer from little-endian byte order.- Parameters:
src- the source byte arraysi- the starting index in the source array- Returns:
- the decoded integer value
-
enc_uint64be
public static int enc_uint64be(long l, byte[] dst, int di) Encodes a 64-bit unsigned integer in big-endian byte order.- Parameters:
l- the long value to encodedst- the destination byte arraydi- the starting index in the destination array- Returns:
- the number of bytes written (8)
-
enc_uint64le
public static int enc_uint64le(long l, byte[] dst, int di) Encodes a 64-bit unsigned integer in little-endian byte order.- Parameters:
l- the long value to encodedst- the destination byte arraydi- the starting index in the destination array- Returns:
- the number of bytes written (8)
-
dec_uint64be
public static long dec_uint64be(byte[] src, int si) Decodes a 64-bit unsigned integer from big-endian byte order.- Parameters:
src- the source byte arraysi- the starting index in the source array- Returns:
- the decoded long value
-
dec_uint64le
public static long dec_uint64le(byte[] src, int si) Decodes a 64-bit unsigned integer from little-endian byte order.- Parameters:
src- the source byte arraysi- the starting index in the source array- Returns:
- the decoded long value
-
enc_floatle
public static int enc_floatle(float f, byte[] dst, int di) Encodes a float value in little-endian byte order.- Parameters:
f- the float value to encodedst- the destination byte arraydi- the starting index in the destination array- Returns:
- the number of bytes written (4)
-
enc_floatbe
public static int enc_floatbe(float f, byte[] dst, int di) Encodes a float value in big-endian byte order.- Parameters:
f- the float value to encodedst- the destination byte arraydi- the starting index in the destination array- Returns:
- the number of bytes written (4)
-
dec_floatle
public static float dec_floatle(byte[] src, int si) Decodes a float value from little-endian byte order.- Parameters:
src- the source byte arraysi- the starting index in the source array- Returns:
- the decoded float value
-
dec_floatbe
public static float dec_floatbe(byte[] src, int si) Decodes a float value from big-endian byte order.- Parameters:
src- the source byte arraysi- the starting index in the source array- Returns:
- the decoded float value
-
enc_doublele
public static int enc_doublele(double d, byte[] dst, int di) Encodes a double value in little-endian byte order.- Parameters:
d- the double value to encodedst- the destination byte arraydi- the starting index in the destination array- Returns:
- the number of bytes written (8)
-
enc_doublebe
public static int enc_doublebe(double d, byte[] dst, int di) Encodes a double value in big-endian byte order.- Parameters:
d- the double value to encodedst- the destination byte arraydi- the starting index in the destination array- Returns:
- the number of bytes written (8)
-
dec_doublele
public static double dec_doublele(byte[] src, int si) Decodes a double value from little-endian byte order.- Parameters:
src- the source byte arraysi- the starting index in the source array- Returns:
- the decoded double value
-
dec_doublebe
public static double dec_doublebe(byte[] src, int si) Decodes a double value from big-endian byte order.- Parameters:
src- the source byte arraysi- the starting index in the source array- Returns:
- the decoded double value
-
enc_time
Encodes a Date value according to the specified time encoding type.- Parameters:
date- the Date to encodedst- the destination byte arraydi- the starting index in the destination arrayenc- the time encoding type (e.g., TIME_1970_SEC_32BE)- Returns:
- the number of bytes written
-
dec_time
Decodes a Date value according to the specified time encoding type.- Parameters:
src- the source byte arraysi- the starting index in the source arrayenc- the time encoding type (e.g., TIME_1970_SEC_32BE)- Returns:
- the decoded Date value
-
enc_utf8
Encodes a String as UTF-8 bytes.- Parameters:
str- the String to encodedst- the destination byte arraydi- the starting index in the destination arraydlim- the maximum index in the destination array- Returns:
- the number of bytes written
- Throws:
IOException- if an encoding error occurs
-
dec_utf8
Decodes a UTF-8 encoded string from a byte array.- Parameters:
src- the source byte arraysi- the starting index in the source arrayslim- the limit index in the source array- Returns:
- the decoded String
- Throws:
IOException- if a decoding error occurs
-
dec_ucs2le
Decodes a UCS-2 little-endian encoded string from a byte array.- Parameters:
src- the source byte arraysi- the starting index in the source arrayslim- the limit index in the source arraybuf- the character buffer for decoding- Returns:
- the decoded String
- Throws:
IOException- if a decoding error occurs
-