Common string operations (padding, chunks, base64)¶
Supports most common string operations e.g.:
- packing/unpacking:
p64()
,p32()
,p16()
,p8()
u64()
,u32()
,u16()
,u8()
chunks:
chunks_iter()
,chunks()
chunks/chunks_iter¶
asciiz/utf16z¶
Padding (null/pkcs7)¶
-
malduck.
pad
(s, block_size)¶ Padding PKCS7/NULL
-
malduck.
unpad
(s)¶ Unpadding PKCS7/NULL
Packing/unpacking (p64/p32/p16/p8, u64/u32/u16/u8, bigint)¶
-
malduck.
uint64
(other, offset=0, fixed=True)¶ Unpacks single value from provided buffer with little-endian order
- Parameters
other (bytes) – Buffer object containing value to unpack
offset (int) – Buffer offset
fixed (bool (default: True)) – Convert to fixed-size integer (IntType instance)
- Return type
IntType instance or None if there are not enough data to unpack
Warning
Fixed-size integer operations are 4-5 times slower than equivalent on built-in integer types
-
malduck.
uint32
(other, offset=0, fixed=True)¶ Unpacks single value from provided buffer with little-endian order
- Parameters
other (bytes) – Buffer object containing value to unpack
offset (int) – Buffer offset
fixed (bool (default: True)) – Convert to fixed-size integer (IntType instance)
- Return type
IntType instance or None if there are not enough data to unpack
Warning
Fixed-size integer operations are 4-5 times slower than equivalent on built-in integer types
-
malduck.
uint16
(other, offset=0, fixed=True)¶ Unpacks single value from provided buffer with little-endian order
- Parameters
other (bytes) – Buffer object containing value to unpack
offset (int) – Buffer offset
fixed (bool (default: True)) – Convert to fixed-size integer (IntType instance)
- Return type
IntType instance or None if there are not enough data to unpack
Warning
Fixed-size integer operations are 4-5 times slower than equivalent on built-in integer types
-
malduck.
uint8
(other, offset=0, fixed=True)¶ Unpacks single value from provided buffer with little-endian order
- Parameters
other (bytes) – Buffer object containing value to unpack
offset (int) – Buffer offset
fixed (bool (default: True)) – Convert to fixed-size integer (IntType instance)
- Return type
IntType instance or None if there are not enough data to unpack
Warning
Fixed-size integer operations are 4-5 times slower than equivalent on built-in integer types
-
malduck.
u64
(other, offset=0, fixed=True)¶ Unpacks single value from provided buffer with little-endian order
- Parameters
other (bytes) – Buffer object containing value to unpack
offset (int) – Buffer offset
fixed (bool (default: True)) – Convert to fixed-size integer (IntType instance)
- Return type
IntType instance or None if there are not enough data to unpack
Warning
Fixed-size integer operations are 4-5 times slower than equivalent on built-in integer types
-
malduck.
u32
(other, offset=0, fixed=True)¶ Unpacks single value from provided buffer with little-endian order
- Parameters
other (bytes) – Buffer object containing value to unpack
offset (int) – Buffer offset
fixed (bool (default: True)) – Convert to fixed-size integer (IntType instance)
- Return type
IntType instance or None if there are not enough data to unpack
Warning
Fixed-size integer operations are 4-5 times slower than equivalent on built-in integer types
-
malduck.
u16
(other, offset=0, fixed=True)¶ Unpacks single value from provided buffer with little-endian order
- Parameters
other (bytes) – Buffer object containing value to unpack
offset (int) – Buffer offset
fixed (bool (default: True)) – Convert to fixed-size integer (IntType instance)
- Return type
IntType instance or None if there are not enough data to unpack
Warning
Fixed-size integer operations are 4-5 times slower than equivalent on built-in integer types
-
malduck.
u8
(other, offset=0, fixed=True)¶ Unpacks single value from provided buffer with little-endian order
- Parameters
other (bytes) – Buffer object containing value to unpack
offset (int) – Buffer offset
fixed (bool (default: True)) – Convert to fixed-size integer (IntType instance)
- Return type
IntType instance or None if there are not enough data to unpack
Warning
Fixed-size integer operations are 4-5 times slower than equivalent on built-in integer types