Untitled

mail@pastecode.io avatar
unknown
plain_text
10 days ago
541 B
2
Indexable
Never
def get_dbs_id(string):
    partial_parts = [(0, 0.1), (0.45, 0.50), (0.65, 0.85),(0.9, 1)]
    str_count = len(string)
    slice_parts = [(int(_min*str_count), int(_max*str_count)) for _min, _max in partial_parts]
    dbs_id = []
    for _min, _max in slice_parts:
        if _max - _min > 400:
            dbs_id.append(string[_min: _min + 400])
        else:
            dbs_id.append(string[_min: _max])
    return '-'.join(dbs_id)


# Sample use:
# convert databytes with base64 str
dbs_id = get_dbs_id(data_base64_str)
Leave a Comment