Initial commit

This commit is contained in:
2025-01-20 00:22:55 +01:00
commit c9aa86f73d
5 changed files with 45 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
bazel-*/

1
BUILD Normal file
View File

@ -0,0 +1 @@

6
MODULE.bazel Normal file
View File

@ -0,0 +1,6 @@
module(
name = "bazel_registry",
version = "0.0.0",
compatibility_level = 1,
)

3
bazel_registry.json Normal file
View File

@ -0,0 +1,3 @@
{
"mirrors": []
}

34
integrity.py Normal file
View File

@ -0,0 +1,34 @@
import sys
import hashlib
import base64
from pathlib import Path
import requests
def file_hash(file_path: Path) -> str:
sha256_hash = hashlib.sha256()
with open(file_path, "rb") as file:
while True:
data = file.read(65536)
if not data:
break
sha256_hash.update(data)
return "sha256-" + base64.b64encode(sha256_hash.digest()).decode()
def url_hash(url: str) -> str:
sha256_hash = hashlib.sha256()
with requests.get(url, stream=True) as resp:
resp.raise_for_status()
while True:
data = resp.raw.read(65536)
if not data:
break
sha256_hash.update(data)
return "sha256-" + base64.b64encode(sha256_hash.digest()).decode()
if __name__ == "__main__" and len(sys.argv) > 1:
path = Path(sys.argv[1])
if path.exists():
print(file_hash(path))
else:
print(url_hash(sys.argv[1]))