Initial commit

This commit is contained in:
2024-07-13 00:53:45 +03:00
commit 00eabc8150
25 changed files with 870 additions and 0 deletions

25
git/get_hash.py Normal file
View File

@@ -0,0 +1,25 @@
import hashlib
import zlib
import sys
def calculate_git_hash(file_path):
# Read the file content
with open(file_path, 'rb') as f:
content = f.read()
# Decompress the zlib-compressed content
decompressed_content = zlib.decompress(content)
# Calculate the SHA-1 hash of the decompressed content
sha1 = hashlib.sha1(decompressed_content).hexdigest()
return sha1
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python get_hash.py <path_to_git_object_file>")
else:
file_path = sys.argv[1]
hash_value = calculate_git_hash(file_path)
print(f"{hash_value}")