-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import binascii | ||
import hashlib | ||
|
||
text = '''The quick brown fox jumps over the lazy dog | ||
Τhe quick brown fox jumps over the lazy dog | ||
Тhe quick brown fox jumps over the lazy dog | ||
''' | ||
|
||
# tips for obfuscation | ||
assert 'i' != 'і' and 'T' != 'Τ' | ||
|
||
# Supported: md5 sha1 sha224 sha256 sha384 sha512 blake2b blake2s sha3_224 sha3_256 sha3_384 sha3_512 | ||
hash_function = hashlib.sha256 | ||
digest_size = len(hash_function(b'').digest()) | ||
result_digest = b'\0' * digest_size | ||
lines = text.splitlines(keepends=False) | ||
charset = set() | ||
for line in lines: | ||
charset.update(set(line)) | ||
data = line.encode('utf8') | ||
line_hash = hash_function(data) | ||
result_digest = bytes(a ^ b for a, b in zip(result_digest, line_hash.digest())) | ||
print(line_hash.hexdigest(), data) | ||
result_hash_line = binascii.hexlify(result_digest).decode('ascii') | ||
print('--' * digest_size) | ||
print(result_hash_line, 'lines:', len(lines), 'chars:', len(charset)) |