mirror of
https://github.com/adulau/HHHash.git
synced 2024-12-22 08:46:05 +00:00
chg: [doc] updated docstring to Markdown format
This commit is contained in:
parent
a8e025f087
commit
9ccb144c18
1 changed files with 16 additions and 10 deletions
|
@ -6,11 +6,13 @@ def buildhash(url=None, debug=False, method='GET', timeout=5):
|
||||||
"""Build a HHHash from an HTTP request to specific url.
|
"""Build a HHHash from an HTTP request to specific url.
|
||||||
|
|
||||||
Keyword arguments:
|
Keyword arguments:
|
||||||
url -- the url to build the HHHash from the response headers (default None)
|
- `url` -- the url to build the HHHash from the response headers (default None)
|
||||||
debug -- output the headers returned before hashing (default False)
|
- `debug` -- output the headers returned before hashing (default False)
|
||||||
method -- HTTP method to use (GET or HEAD) (default GET)
|
- `method` -- HTTP method to use (GET or HEAD) (default GET)
|
||||||
timeout -- default timeout for the connect/read timeout of request (default 2)
|
- `timeout` -- default timeout for the connect/read timeout of request (default 2)
|
||||||
"""
|
|
||||||
|
For more details about the [HHHash algorithm](https://www.foo.be/2023/07/HTTP-Headers-Hashing_HHHash).
|
||||||
|
"""
|
||||||
if url is None:
|
if url is None:
|
||||||
return False
|
return False
|
||||||
if method == 'GET':
|
if method == 'GET':
|
||||||
|
@ -33,10 +35,12 @@ def hash_from_banner(banner, debug=False):
|
||||||
"""Create a HHHash from an already fetched banner. Lines without colons will be skipped.
|
"""Create a HHHash from an already fetched banner. Lines without colons will be skipped.
|
||||||
|
|
||||||
Keyword arguments:
|
Keyword arguments:
|
||||||
banner -- HTTP banner string
|
- `banner` -- HTTP banner as a string
|
||||||
debug -- output the headers returned before hashing
|
- `debug` -- output the headers returned before hashing
|
||||||
|
|
||||||
Example:
|
Example usage:
|
||||||
|
|
||||||
|
```
|
||||||
>>> hash_from_banner('''HTTP/1.1 200 OK
|
>>> hash_from_banner('''HTTP/1.1 200 OK
|
||||||
... Content-Type: text/html; charset=ISO-8859-1
|
... Content-Type: text/html; charset=ISO-8859-1
|
||||||
... Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-iV-j91UJEG2jNx4j6EeTug' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
|
... Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-iV-j91UJEG2jNx4j6EeTug' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
|
||||||
|
@ -53,6 +57,8 @@ def hash_from_banner(banner, debug=False):
|
||||||
... Set-Cookie: <removed>
|
... Set-Cookie: <removed>
|
||||||
... Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000''')
|
... Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000''')
|
||||||
hhh:1:d9576f3e7a381562f7d18a514ab095fa8699e96891d346d0042f83e942373215
|
hhh:1:d9576f3e7a381562f7d18a514ab095fa8699e96891d346d0042f83e942373215
|
||||||
|
|
||||||
|
```
|
||||||
"""
|
"""
|
||||||
hhhash = ""
|
hhhash = ""
|
||||||
for line in banner.splitlines():
|
for line in banner.splitlines():
|
||||||
|
|
Loading…
Reference in a new issue