0
0
Gitdevops~20 mins

SHA-1 hashing concept in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SHA-1 Hashing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What does SHA-1 hashing in Git uniquely identify?

In Git, SHA-1 hashes are used to identify objects. What exactly does a SHA-1 hash uniquely identify?

AThe content of a file or commit, ensuring integrity and uniqueness
BThe file name and its location in the repository
CThe date and time when the commit was made
DThe user who made the commit
Attempts:
2 left
💡 Hint

Think about what Git uses to detect changes and avoid duplicates.

💻 Command Output
intermediate
1:30remaining
Output of SHA-1 hash command on a file

What is the output of the following command if the file example.txt contains the text Hello?

git hash-object example.txt
Ada39a3ee5e6b4b0d3255bfef95601890afd80709
B2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
Caaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
De69de29bb2d1d6434b8b29ae775ad8c2e48c5391
Attempts:
2 left
💡 Hint

Check the SHA-1 hash of the string 'Hello' without newline.

Troubleshoot
advanced
2:00remaining
Why does Git show different SHA-1 hashes for identical file content?

You have two files with exactly the same content, but git hash-object shows different SHA-1 hashes for each. What could cause this?

AThe files are in different folders
BThe files have different file names
CGit caches the hash and shows old values
DOne file has different line endings (CRLF vs LF)
Attempts:
2 left
💡 Hint

Think about invisible characters that affect file content.

🔀 Workflow
advanced
2:30remaining
Order of Git object creation and SHA-1 hashing

Arrange the steps Git follows when creating a commit object and calculating its SHA-1 hash.

A1,2,3,4
B2,1,3,4
C1,3,2,4
D3,1,2,4
Attempts:
2 left
💡 Hint

Think about how Git builds from directory snapshot to commit storage.

Best Practice
expert
3:00remaining
Why is SHA-1 considered weak for Git security and what is Git's response?

SHA-1 hashing is known to have vulnerabilities. Why is this a concern for Git, and what approach has Git taken to address it?

ASHA-1 hashes are too long; Git shortened them to 8 characters to save space.
BSHA-1 collisions can allow fake commits; Git is transitioning to SHA-256 hashing for stronger security.
CSHA-1 is slow; Git replaced it with MD5 for faster hashing.
DSHA-1 is proprietary; Git switched to a custom hashing algorithm.
Attempts:
2 left
💡 Hint

Consider cryptographic weaknesses and Git's recent updates.