bitsbehumble 0.6

Last updated:

0 purchases

bitsbehumble 0.6 Image
bitsbehumble 0.6 Images
Add to Cart

Description:

bitsbehumble 0.6

bitsbehumble
BitsBeHumble is a lightweight type converter python library. it is designed to make CTF scripting a wee bit easier.
Its main purpose is to save you the googling time you spend every time you need to convert from one type to another, convert endianness or simply convert a binary array to a binary string.
It doesn't support unicode, yet.
>>> string_to_hex('Hello World!',end='little')
>>> 0x21646c726f57206f6c6c6548

>>> binary_to_string('0100100001100101011011000110110001101111')
>>> Hello

>>> little_to_big_endian(0x21646c726f57206f6c6c6548)
>>> 0x48656c6c6f20576f726c6421

>>> hex_to_binary('0x48656c6c6f20576f726c64',ret='list')
>>> ['0b1001000', '0b1100101', '0b1101100', '0b1101100', '0b1101111', '0b100000', '0b1010111', '0b1101111', '0b1110010', '0b1101100', '0b1100100']


Installation
pip install bitsbehumble

Contribution
Pull requests , Ideas and feedback are welcomed.
Documentation
Naming convetion: type_to_type().
Default return type: same type as the first argument unless specified otherwise.
Available return types :ret='list', ret='int' , ret='str'.
Default Endianness: big-endian
Available Endianness: end='big' , end='little'
All functions accept all 3 types of arguments ( int, str, list ) with or without prefixes ('0x' , '0b') unless specified otherwise in the function name, for example:
binstr_to_binarray(bin_str)
binarray_to_binstr(bin_arr)
string_to_binary(string, ret='default')
hexstring_to_array(hex_str)
hexarr_to_hexstring(hex_array)
string_to_hex(string ,end='big',ret='str')


Available Functions
hex_to_binary(hx,ret='default')

params: hx(any type)
ret (str): 'int', 'str' or 'list'
default return type: (same as hx)
binary_to_hex(b,ret='default')

params: b (any type)
ret (str): 'int', 'str' or 'list'
default return type: (same as b)
hex_to_string(hx)

can also be called like this: unhexlify(hx)
params: hx (any type)
default return type: (str)
binary_to_string(b):

params: b (any type)
default return type: (str)
string_to_binary(string, ret='default')

params: string (str)
ret (str): 'int', 'str' or 'list'
default return type: (same as string)
string_to_hex(string ,end='big',ret='str')

can also be called like this: hexlify(string ,end='big',ret='str')
params: string (str)
end (str) : 'big' or 'little'
ret (str): 'int', 'str' or 'list'
default return type: (str)
little_to_big_endian(hx,ret='default')

params: hx (any type)
ret (str): 'int', 'str' or 'list'
default return type: (same as hx)
big_to_little_endian(hx,ret='default')

params: hx (any type)
ret (str): 'int', 'str' or 'list'
default return type: (same as hx)
zero_extend(b,n,at='start')

works like python's zfill.
for binary strings: extends them to a length divisible by 8 if (n) isn't specified.
if n is specified it adds (n) zeros to the start or the end of the string.
for strings: does nothing if (n) isn't specified.
if n is specified it adds (n) zeros to the start or the end of the string.
params: b (string)
n (int)
at (str) 'start' or 'end'
default return type: (string)
hexarr_to_hexstring(hex_array)

params: hex_array (list)
default return type: (str)
binstr_to_binarray(bin_str)

params: bin_str (str)
default return type: (list)
binarray_to_binstr(bin_arr)

params: bin_arr (list)
default return type: (str)
to_binstr(b)

takes a binary of any type and returns a binary string
params: b (any type)
default return type: (str)
string_to_bytes(string,ret='default')

params: string (str)
ret (str): 'int', 'str' or 'list'
default return type: (same as string)
bytes_to_string(b)

params: b (any type) : str , int , bytes, bytearray or list of any type.
default return type: (str)
hexstring_to_array(hex_str):

params: hex_str (string)
default return type: (list)
to_hexstr(hx)

takes a hex int/str/bytes/list/bytearray and returns the string representation of it
params: hx (any type)
default return type: (str)
hex_to_bytes(hx)

params: hx (any type)
default return type: (bytes)
is_valid_hex(hx)

params: hx (any type)
default return type: (bool)
is_valid_binary(b)

params: b (any type)
default return type: (bool)
getKey(dct,value)

searches a given dictionary for the key of the given value and returns a list of one or more keys
params: dct (dict)
value (any type)
default return type: (list)

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.