java.lang.Object
org.codelibs.jcifs.smb.util.Encdec
Encoding and decoding utility class for SMB protocol.
Provides methods for encoding/decoding various data types in different byte orders.
-
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.
-
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
-
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
-