Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Script to write the version file #18

Open
TrevorBrunette opened this issue Feb 28, 2022 · 0 comments
Open

[FEATURE] Script to write the version file #18

TrevorBrunette opened this issue Feb 28, 2022 · 0 comments

Comments

@TrevorBrunette
Copy link
Contributor

The version metadata file should be a JSON file containing all of the checksums of the JSON files, this way the files do not need to be redownloaded if only one of them changes. We will use SHA-256 as the hashing algorithm.
if there are two files, courses.json and majors.json, then the meta.json file should look like:

{
  "courses": "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
  "majors": "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
}

We need a script to automatically do this: given a predefined list of file names, find the SHA-256 hash for each one if it exists in the working directory, encode it into HEX (64 characters since this is SHA-256) and write it into the meta.json file as described above.

If you decide to use python, consider the following code

hashlib.sha256(bytes).hexdigest()

for smaller files, or

for byte_block in iter(lambda: f.read(4096),b""):
        sha256_hash.update(byte_block)

for larger files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant