DataFormat

class chepy.modules.dataformat.DataFormat(*data)
binary_to_hex() DataFormatT

Converts binary data into a hex string

Returns

The Chepy object.

Return type

Chepy

bruteforce_from_base_xx() DataFormatT

Bruteforce various base encodings. Current supports base85, base16, base32, base64, base85, base58

Returns

The Chepy object.

Return type

Chepy

bytearray_to_str(encoding: str = 'utf8', errors: str = 'replace') DataFormatT

Convert a python bytearray to string

Parameters
  • encoding (str, optional) – String encoding. Defaults to ‘utf8’.

  • errors (str, optional) – How errors should be handled. Defaults to replace.

Raises

TypeError – If state is not a bytearray

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy(bytearray("lolol", "utf")).bytearray_to_str().o
"lolol"
bytes_to_ascii() DataFormatT

Convert bytes (array of bytes) to ascii

Returns

The Chepy object.

Return type

Chepy

bytes_to_long() DataFormatT

Bytes to long

Returns

The Chepy object.

Return type

Chepy

concat(data: Union[str, bytes]) DataFormatT

Concat bytes to the current state

Parameters

data (Union[str, bytes]) – Data to add

Returns

The Chepy object. s

Return type

Chepy

cut(start: int, end: int) DataFormatT

Convert the state to bytes and cut x:y data from it

Parameters
  • start (int) – Starting position

  • end (int) – End position

Returns

The Chepy object.

Return type

Chepy

decode_bruteforce() DataFormatT

Bruteforce the various decoding for a string

Enumerates all supported text encodings for the input, allowing you to quickly spot the correct one. Reference

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("m\xfcnchen\ud55c").decode_bruteforce()
{
    ...
    'unicode_escape': 'münchen한',
    'utf_16': '屭晸湣档湥畜㕤挵',
    'utf_16_be': '浜硦据捨敮屵搵㕣',
    ...
}
decode_bytes(errors: str = 'ignore') DataFormatT

Decode bytes to string

Parameters

errors (str, optional) – Ignore or replace error chars. Defaults to ‘ignore’.

Returns

The Chepy object.

Return type

Chepy

decrement_bytes(n: int) DataFormatT

Loop through each byte and decrement

Parameters

n (int) – decrement by.

Returns

The Chepy object.

Return type

Chepy

dict_get_items(*keys: str) DataFormatT

Get items from a dict. If no keys are specified, it will return all items. :returns: The Chepy object. :rtype: Chepy

Examples

>>> o = Chepy({"a": 1, "b": 2}).dict_get_items("a", "b", "c").o
[1, 2]
dict_to_json() DataFormatT

Convert a dict object to a JSON string

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy({"some": "data", "a": ["list", 1, True]}).dict_to_json().o
'{"some":"data","a":["list",1,true]}'
encode_bruteforce() DataFormatT

Bruteforce the various encoding for a string

Enumerates all supported text encodings for the input, allowing you to quickly spot the correct one. Reference

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("münchen한").encode_bruteforce()
{
    'ascii': b'm\xfcnchen\ud55c',
    'base64_codec': b'bcO8bmNoZW7tlZw=\n',
    'big5': b'm\xfcnchen\ud55c',
    'big5hkscs': b'm\x88\xa2nchen\ud55c',
    ...
}
eval_state() DataFormatT

Eval state as python. Handy when converting string representation of objects.

Returns

The Chepy object

Return type

Chepy

flatten() DataFormatT

Flatten a list of lists into a single list

Returns

The Chepy object.

Return type

Chepy

from_bacon(A: Literal['A', '0'] = 'A', B: Literal['B', '1'] = 'B', complete: bool = True, split_by: Union[str, bytes] = b' ', invert: bool = False) DataFormatT

From Bacon

Parameters
  • A (Literal['A','0'], optional) – A character. Defaults to ‘A’.

  • B (str, optional) – B character. Defaults to ‘B’.

  • complete (bool, optional) – Use unique mapping for all characters. Defaults to True.

  • split_by (Union[str,bytes], optional) – Split by. Defaults to b’ ‘.

  • invert (bool, optional) – Invert decoding. Defaults to False.

Returns

The Chepy object.

Return type

Chepy

from_base(radix: int = 36) DataFormatT

Convert string to int base

Parameters

radix (int, optional) – Radix. Defaults to 36.

Returns

The Chepy object.

Return type

Chepy

from_base16() DataFormatT

Decode state in base16

Returns

The Chepy object.

Return type

Chepy

from_base32(remove_whitespace: bool = True) DataFormatT

Decode as Base32

Base32 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers. It uses a smaller set of characters than Base64, usually the uppercase alphabet and the numbers 2 to 7.

Parameters

remove_whitespace (bool, optional) – If true, all whitespaces are removed

Returns

The Chepy object.

Return type

Chepy

from_base36(delimiter: Union[str, bytes] = ' ', join_by: Union[str, bytes] = ' ') DataFormatT

Decode Base36 data

Parameters
  • delimiter (Union[str, bytes], optional) – Delimiter to split groups of ints by. Defaults to ‘ ‘.

  • join_by (Union[str, bytes], optional) – Join final output by. Defaults to ‘ ‘.

Returns

The Chepy object.

Return type

Chepy

from_base45() DataFormatT

Decode from Base45

Returns

The Chepy object.

Return type

Chepy

from_base58() DataFormatT

Decode as Base58

Base58 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers.This property decodes raw data into an ASCII Base58 string.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("2UDrs31qcWSPi").from_base58().out.decode()
"some data"
from_base62(alphabet: str = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') DataFormatT

Decode from base62

Parameters

alphabet (str, optional) – Alphabet. Defaults to “0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz”.

Returns

The Chepy object.

Return type

Chepy

from_base64(alphabet: str = 'standard', remove_non_alpha: bool = True) DataFormatT

Decode as Base64

Base64 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers.This property decodes raw data into an ASCII Base64 string.

Parameters
  • alphabet (str, optional) – Provide a custom charset to base64 with. Valid values are: filename_safe, itoa64, radix_64, rot13, standard, unix_crypt, url_safe, xml, xxencoding, z64

  • remove_whitespace (bool, optional) – If true, all whitespaces are removed (Defaults to True)

  • remove_non_alpha (bool, optional) – If true, all whitespaces are removed. (Defaults to True)

Returns

The Chepy object.

Return type

Chepy

Examples

Base64 decode using a custom string >>> c = Chepy(“QqxhNG/mMKtYPqoz64FVR42=”) >>> c.from_base64(alphabet=”./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz”) >>> c.out b”some random? data”

from_base85() DataFormatT

Decode as Base85

Base85 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers.This property decodes raw data into an ASCII Base58 string.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("F)Po,+Cno&@/").from_base85().out.decode()
"some data"
from_base91() DataFormatT

Decode as Base91 Reference: https://github.com/aberaud/base91-python/blob/master/base91.py#L42

Returns

The Chepy object.

Return type

Chepy

from_base92() DataFormatT

Decode from Base92

Returns

The Chepy object.

Return type

Chepy

from_binary(delimiter: str = None, byte_length: int = 8) DataFormatT

Convert a list of binary numbers to string

Parameters
  • delimiter (str, optional) – Delimiter. Defaults to ” “.

  • byte_length (int, optional) – Byte length. Defaults to 8.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("01100001 01100010 01100011").from_binary().o
"abc"
from_braille() DataFormatT

Convert text to six-dot braille symbols

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("⠎⠑⠉⠗⠑⠞⠀⠍⠑⠎⠎⠁⠛⠑").from_braille().o
"secret message"
from_bytes() DataFormatT

Decodes bytes to string.

Returns

The Chepy object.

Return type

Chepy

from_charcode(delimiter: str = None, join_by: str = '', base: int = 10) DataFormatT

Convert array of unicode chars to string

Parameters
  • delimiter (str, optional) – Delimiter. Defaults to ” “.

  • join_by (str, optional) – Join by. Defaults to “”.

  • base (int, optional) – Base. Defaults to 10.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("314e 61 20 41"]).from_charcode().o
"ㅎa A"
from_decimal(delimiter: str = None, join_by: str = '') DataFormatT

Convert a list of decimal numbers to string

Parameters
  • delimiter (str, optional) – Delimiter. Defaults to ” “.

  • join_by (str, optional) – Join by. Defaults to “”.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy(12622).from_decimal().o
"ㅎ"
from_hex(delimiter: str = None, join_by: str = '', replace: Optional[bytes] = b'%|0x') DataFormatT

Convert a non delimited hex string to string

Parameters
  • delimiter (str, optional) – Delimiter. Defaults to None.

  • join_by (str, optional) – Join by. Defaults to ‘ ‘.

  • replace (Union[bytes, None], optional) – Regex pattern to replace hex string prefixes. Defaults to b’%x|0x’.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("414141").from_hex().out
b"AAA"
from_hexdump() DataFormatT

Convert hexdump back to str

Returns

The Chepy object.

Return type

Chepy

from_html_entity() DataFormatT

Decode html entities

Decode special html characters like & > < etc

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("https://google.com&amp;a=&quot;lol&quot;").from_html_entity().o
'https://google.com&a="lol"'
from_messagepack() DataFormatT

From MessagePack

Returns

The Chepy object.

Return type

Chepy

from_nato(delimiter: Optional[str] = None, join_by: str = '') DataFormatT

Translate NATO phoentic to words

Parameters
  • delimiter (str, optional) – Delimiter to split on. Defaults to ‘ ‘.

  • join_by (str, optional) – Join result by. Defaults to ‘’.

Returns

The Chepy object

Return type

Chepy

from_octal(delimiter: str = None, join_by: str = '') DataFormatT

Convert a list of octal numbers to string

Parameters
  • delimiter (str, optional) – Delimiter. Defaults to None.

  • join_by (str, optional) – Join by. Defaults to “”.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("141 142").from_octal().o
"ab"
from_pickle(trust: bool = False) DataFormatT

Deserialize pickle data

Parameters

trust (bool, optional) – As this can lead to code execution, this is a safety net and needs to be set to True. Defaults to False.

Returns

The Chepy object.

Return type

Chepy

from_punycode() DataFormatT

Decode to punycode

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy(b"mnchen-3ya").from_punycode().o
"münchen"
from_quoted_printable() DataFormatT

From quoted printable

Returns

The Chepy object.

Return type

Chepy

from_rison() DataFormatT

Encode to RISON

Returns

The Chepy object.

Return type

Chepy

from_twin_hex() DataFormatT

Decode twin hex

Returns

The Chepy object.

Return type

Chepy

from_upside_down(reverse: bool = False)

From upside down

Parameters

reverse (bool, optional) – Reverse order. Defaults to False.

Returns

The Chepy object.

Return type

Chepy

from_url_encoding() DataFormatT

Converts URI/URL percent-encoded characters back to their raw values.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("https://google.com/%3Flol%3Dsome+data%26a%3D1").from_url_encoding().o
"https://google.com/?lol=some data&a=1"
from_utf21() DataFormatT

Convert from UTF-21

Returns

The Chepy object.

Return type

Chepy

from_uuencode(header: str = '-') DataFormatT

From UUEncode

Parameters

header (str) – header

Returns

The Chepy object.

Return type

Chepy

from_wingdings() DataFormatT

Decode from windings

Returns

The Chepy object.

Return type

Chepy

hex_to_bytes() DataFormatT

Hex to bytes hex

Converts a hex string to its bytes form. Example: 41 becomes x41

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("ab00").hex_to_bytes().o
b"\xab\x00"
hex_to_int() DataFormatT

Converts hex into its integer representation

Returns

The Chepy object.

Return type

Chepy

Examples

Chepy works with hex characters that start with a 0x

>>> Chepy("0x123").hex_to_int().out
291

Without 0x in the hex

>>> Chepy("123").hex_to_int().out
291
hex_to_str(ignore: bool = False) DataFormatT

Decodes a hex string to ascii ignoring any decoding errors

Parameters

ignore (bool, optional) – Ignore errors, by default False

Returns

The Chepy object.

Return type

Chepy

Examples

To ignore UnicodeDecode errors, set ignore to True >>> Chepy(“4100”).hex_to_str(ignore=True).o “A"

increment_bytes(n: int) DataFormatT

Loop through each byte and increment

Parameters

n (int) – increment by.

Returns

The Chepy object.

Return type

Chepy

int_to_hex() DataFormatT

Converts an integer into its hex equivalent

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy(101).int_to_hex().o
"65"
int_to_str() DataFormatT

Converts an integer into a string

Returns

The Chepy object.

Return type

Chepy

join(join_by: Union[str, bytes] = '') DataFormatT

Join a list with specified character

Parameters

join_by (Union[str, bytes], optional) – What to join with. Defaults to “”

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy(["a", "b", "c"]).join_list(":").o
"a:b:c"
json_to_dict() DataFormatT

Convert a JSON string to a dict object

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy('{"some": "data", "a": ["list", 1, true]}').json_to_dict().o
{
    "some": "data",
    "a": ["list", 1, True],
}
json_to_yaml() DataFormatT

Convert a json string to yaml structure

Returns

The Chepy object.

Return type

Chepy

length() DataFormatT

Get the length of the current state as string

Returns

The Chepy object.

Return type

Chepy

list_to_str(join_by: Union[str, bytes] = ' ') DataFormatT

Join an array by join_by

Parameters

join_by (Union[str, bytes], optional) – String character to join by, by default ‘ ‘

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy(["a", "b", "c"]).list_to_str(",").o
"a,b,c"
long_to_bytes() DataFormatT

Long numbers to bytes

Returns

The Chepy object.

Return type

Chepy

normalize_hex(is_bytearray=False) DataFormatT

Normalize a hex string

Removes special encoding characters from a hex string like %, 0x, , :, ;, n and rn

Parameters

is_bytearray (bool, optional) – Set to True if state is a bytearray

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("41:42:CE").normalize_hex().o
"4142CE"
>>> Chepy("0x410x420xce").normalize_hex().o
"4142ce"
parse_csv() DataFormatT

Parse a csv file. Returns a list of dict objects.

Returns

The Chepy object.

Return type

Chepy

parse_sqlite(query: str) DataFormatT

Parse sqlite db and run queries against it. Returns an array of dict objects with column as key and value

Parameters

query (str) – SQL Query

Returns

The Chepy object.

Return type

Chepy

remove_nonprintable(replace_with: Union[str, bytes] = b'') DataFormatT

Remove non-printable characters from string.

Parameters

replace_with (bytes, optional) – Replace non-printable characters with this. Defaults to ‘’.

Returns

The Chepy object.

Return type

Chepy

rotate_left(radix: int = 1, carry: bool = False) DataFormatT

Rotate left

Parameters
  • radix (int, optional) – Radix. Defaults to 1.

  • carry (bool, optional) – Carry. Defaults to False.

Returns

The Chepy object.

Return type

Chepy

rotate_right(radix: int = 1, carry: bool = False) DataFormatT

Rotate right

Parameters
  • radix (int, optional) – Radix. Defaults to 1.

  • carry (bool, optional) – Carry. Defaults to False.

Returns

The Chepy object.

Return type

Chepy

select(start: int, end: int = None) DataFormatT

Get an item by specifying an index

Parameters
  • start (int) – Starting index number to get

  • end (int, optional) – Ending index number to get. If none specified, will be end of item. Defaults to None.

Returns

The Chepy object.

Return type

Chepy

str_from_hexdump() DataFormatT

Extract a string from a hexdump

Returns

The Chepy object.

Return type

Chepy

str_list_to_list() DataFormatT

Convert a string list to a list

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("[1,2,'lol', true]").str_list_to_list().o
[1, 2, "lol", True]
str_to_dict() DataFormatT

Convert string to a dictionary

Returns

The Chepy object.

Return type

Chepy

str_to_hex() DataFormatT

Converts a string to a hex string

Returns

The Chepy object.

Return type

Chepy

str_to_list() DataFormatT

Convert string to list

Converts the string in state to an array of individual characyers

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("abc").str_to_list().o
["a", "b", "c"]
stringify(compact: bool = True) DataFormatT

Stringify the state. This uses json.dumps unlike to_string

Parameters

compact (bool, optional) – If the output should be compact. Defaults to True.

Returns

The Chepy object.

Return type

Chepy

substitute(x: str, y: str) DataFormatT

Replace a subset of specified characters in the state.

Parameters
  • x (str) – Chars to replace

  • y (str) – Chars to replace with

Returns

The Chepy object.

Return type

Chepy

swap_endianness(word_length: int = 4) DataFormatT

Swap endianness.

Parameters

word_length (int, optional) – Word length. Use 8 for big endian. Defaults to 4.

Returns

The Chepy object.

Return type

Chepy

swap_strings(by: int) DataFormatT

Swap characters in string

Parameters

by (int) – Number of bytes to swap

Returns

The Chepy object

Return type

Chepy

to_bacon(A: Literal['A', '0'] = 'A', B: Literal['B', '1'] = 'B', complete: bool = True, join_by: Union[str, bytes] = b' ', invert: bool = False) DataFormatT

Bacon encode

Parameters
  • A (Literal['A', '0'], optional) – The A character. Defaults to ‘A’.

  • B (Literal['B', '1'], optional) – The B character. Defaults to ‘B’.

  • complete (bool, optional) – Use unique mapping for all characters. Defaults to True.

  • join_by (Union[str,bytes], optional) – Join output by. Defaults to b’ ‘.

  • invert (bool, optional) – Invert encoding. Defaults to False.

Returns

The Chepy object.

Return type

Chepy

to_base(radix: int = 36) DataFormatT

Convert int to base

Parameters

radix (int, optional) – Radix. Defaults to 36.

Returns

The Chepy object.

Return type

Chepy

to_base16() DataFormatT

Encode state in base16

Returns

The Chepy object.

Return type

Chepy

to_base32() DataFormatT

Encode as Base32

Base32 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers. It uses a smaller set of characters than Base64, usually the uppercase alphabet and the numbers 2 to 7.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("some data").base32_encode().out.decode()
"ONXW2ZJAMRQXIYI="
to_base36(join_by: Union[str, bytes] = b' ') DataFormatT

Encode to Base 36

Parameters

join_by (Union[str, bytes], optional) – Join final output by. Defaults to b’ ‘.

Returns

The Chepy object.

Return type

Chepy

to_base45() DataFormatT

Encode to Base45

Returns

The Chepy object.

Return type

Chepy

to_base58() DataFormatT

Encode as Base58

Base58 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers.This property encodes raw data into an ASCII Base58 string.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("some data").to_base58().out.decode()
"2UDrs31qcWSPi"
to_base62(alphabet: str = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') DataFormatT

Encode to base62

Parameters

alphabet (str, optional) – Alphabet. Defaults to “0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz”.

Returns

The Chepy object

Return type

Chepy

to_base64(alphabet: str = 'standard') DataFormatT

Encode as Base64

Base64 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers.This property encodes raw data into an ASCII Base64 string.

Parameters

alphabet (str, optional) – Provide a custom charset to base64 with. Valid values are: filename_safe, itoa64, radix_64, rot13, standard, unix_crypt, url_safe, xml, xxencoding, z64

Returns

The Chepy object.

Return type

Chepy

Examples

>>> # To use a custom character set, use:
>>> custom = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
>>> Chepy("Some data").to_base64(custom=custom).o
b'IqxhNG/YMLFV'
to_base85() DataFormatT

Encode as Base58

Base85 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers.This property decodes raw data into an ASCII Base58 string.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("some data").to_base85().out.decode()
"F)Po,+Cno&@/"
to_base91() DataFormatT

Base91 encode Reference: https://github.com/aberaud/base91-python/blob/master/base91.py#L69

Returns

The Chepy object.

Return type

Chepy

to_base92() DataFormatT

Encode to Base92

Returns

The Chepy object.

Return type

Chepy

to_binary(join_by: Union[str, bytes] = ' ', byte_length: int = 8) DataFormatT

Convert string characters to binary

Parameters
  • join_by (str, optional) – join_by. Defaults to ” “.

  • byte_length (int, optional) – Byte length. Defaults to 8.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("abc").to_binary().o
b"01100001 01100010 01100011"
to_braille() DataFormatT

Convert text to six-dot braille symbols

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("secret message").to_braille().o
"⠎⠑⠉⠗⠑⠞⠀⠍⠑⠎⠎⠁⠛⠑"
to_bytes() DataFormatT

Converts the data in state to bytes

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy({'some': 'val', 'kl': 1}).to_bytes().o
b"{'some': 'val', 'kl': 1}"
to_charcode(join_by: str = ' ', base: int = 16) DataFormatT

Convert a string to a list of unicode charcode

Converts text to its unicode character code equivalent. e.g. Γειά σου becomes 0393 03b5 03b9 03ac 20 03c3 03bf 03c5

Parameters
  • join_by (str, optional) – String to join the charcodes by. Defaults to ‘ ‘.

  • base (int, optional) – Base to use for the charcodes. Defaults to 16.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("aㅎ").to_charcode()
"61 314e"
to_decimal(join_by: str = ' ') DataFormatT

Convert characters to decimal

Parameters

join_by (str, optional) – Join the decimal values by this. Defaults to ‘ ‘.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("aㅎ").to_decimal().o
'97 12622'
to_hex(delimiter: str = '') DataFormatT

Converts a string to its hex representation

Parameters

delimiter (str, optional) – Delimiter. Defaults to None.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("AAA").to_hex().out.decode()
"414141"
to_hexdump() DataFormatT

Convert the state to hexdump

Returns

The Chepy object.

Return type

Chepy

to_html_entity(format='named', all_chars=False) DataFormatT

Encode html entities

Encode special html characters like & > < etc

Parameters
  • format (str) – Encoding format. Valid formats are named, numeric and hex. Defaults to named

  • all_chars (bool) – If all chars should be encoded. By default a-ZA-Z0-9 are skipped. Defaults to False

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy('https://google.com&a="lol"').to_html_entity().o
"https://google.com&amp;a=&quot;lol&quot;"
to_int() DataFormatT

Converts the string representation of a number into an int

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("1").to_int().o
1
to_leetcode(replace_space: str = '') DataFormatT

Convert to leetcode. Reference Reference github.com/ss8651twtw/CTF-flag-generator

Parameters

replace_space (str, optional) – Replace spaces with specified char. Defaults to ‘’.

Returns

The Chepy object.

Return type

Chepy

to_messagepack() DataFormatT

To MessagePack

Returns

The Chepy object.

Return type

Chepy

to_nato(join_by: str = ' ') DataFormatT

Convert string to NATO phonetic format.

Example: abc = Alpha Bravo Charlie

Parameters

join_by (str, optional) – [description]. Defaults to ” “.

Returns

The Chepy object

Return type

Chepy

to_octal(join_by: str = ' ') DataFormatT

Convert string characters to octal

Parameters

join_by (str, optional) – Join by. Defaults to “”.

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("abㅎ").to_octal().o
"141 142 30516"
to_pickle() DataFormatT

Pickle serialize state

Returns

The Chepy object.

Return type

Chepy

to_punycode() DataFormatT

Encode to punycode

Returns

The Chepy object.

Return type

Chepy

Examples

>>> Chepy("münchen").to_punycode().o
b"mnchen-3ya"
to_quoted_printable() DataFormatT

To quoted printable

Returns

The Chepy object.

Return type

Chepy

to_rison() DataFormatT

Decode from RISON

Returns

The Chepy object.

Return type

Chepy

to_string() DataFormatT

Convert to string

Returns

The Chepy object

Return type

Chepy

to_twin_hex() DataFormatT

Encode to twin hex encoding

Returns

The Chepy object.

Return type

Chepy

to_upside_down(reverse: bool = False)

To upside down

Parameters

reverse (bool, optional) – Reverse order. Defaults to False.

Returns

The Chepy object.

Return type

Chepy

to_url_encoding(safe: str = '', all_chars: bool = False) DataFormatT

URL encode

Encodes problematic characters into percent-encoding, a format supported by URIs/URLs.

Parameters
  • safe (str, optional) – String of characters that will not be encoded, by default “”

  • all_chars (bool, optional) – Encode all characters including safe characters

Returns

The Chepy object.

Return type

Chepy

Examples

Url encode while specifying save characters

>>> Chepy("https://google.com/?lol=some data&a=1").to_url_encoding(safe="/:").o
"https://google.com/%3Flol%3Dsome+data%26a%3D1"
to_utf21() DataFormatT

Convert to UTF-21

Returns

The Chepy object.

Return type

Chepy

to_uuencode(header: str = '-') DataFormatT

To UUEncode

Parameters

header (str) – header

Returns

The Chepy object.

Return type

Chepy

to_wingdings() DataFormatT

Encode to windings

Returns

The Chepy object.

Return type

Chepy

trim() DataFormatT

Trim string. Removes whitespaces

Returns

The Chepy object.

Return type

Chepy

unicode_escape(padding: int = 0, uppercase_hex: bool = False) DataFormatT

Unicode escape

Parameters
  • padding (int, optional) – Optional padding. Defaults to 0.

  • uppercase_hex (bool, optional) – Uppercase hex chars. Defaults to False.

Returns

The Chepy object.

Return type

Chepy

yaml_to_json() DataFormatT

Convert yaml to a json string

Returns

The Chepy object.

Return type

Chepy