Quantcast
Channel: Other – Michał Szałkowski – Blog
Viewing all articles
Browse latest Browse all 125

Hex url coder

$
0
0

not perfect, draft

import binascii


def hex_url(_url):

    protocol = ''
    filter = ['?', '=', "/"]

    if _url.startswith('http://'):
        protocol = 'http://'
        _url = _url.replace(protocol, "")

    if _url.startswith('https://'):
        protocol = 'https://'
        _url = _url.replace(protocol, "")

    response = ""
    for _c in _url:
        if _c in filter:
            response += _c
        else:
            response += str(binascii.hexlify(_c.encode('utf8'))).replace("b", "%").replace("'", "")
    print(protocol + response)


hex_url("http://btbw.pl")
hex_url("http://www.blog.btbw.pl")
hex_url("http://bitbeecode.com")
hex_url("https://google.com")


Viewing all articles
Browse latest Browse all 125

Trending Articles