ArticleslgStudy

computer science

Sha1sum

Sha1sum is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Sha1sum rather than just read about it. In short: sha1sum is a computer program that calculates and verifies SHA-1 hashes. It is commonly used to verify the integrity of files.

Key takeaways

  • Sha1sum belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Sha1sum to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Sha1sum from memory before moving on to harder problems.

Reference excerpt

sha1sum is a computer program that calculates and verifies SHA-1 hashes. It is commonly used to verify the integrity of files. It (or a variant) is installed by default on most Linux distributions. Typically distributed alongside sha1sum are sha224sum, sha256sum, sha384sum and sha512sum, which use a specific SHA-2 hash function and b2sum, which uses the BLAKE2 cryptographic hash function. The SHA-1 variants are proven vulnerable to collision attacks, and users should instead use, for example, a SHA-2 variant such as sha256sum or the BLAKE2 variant b2sum to prevent tampering by an adversary. It is included in GNU Core Utilities, Busybox (excluding b2sum), and Toybox (excluding b2sum). Ports to a wide variety of systems are available, including Microsoft Windows.

Examples To create a file with a SHA-1 hash in it, if one is not provided:

If distributing one file, the .sha1 file extension may be appended to the filename e.g.:

The output contains one line per file of the form "{hash} SPACE (ASTERISK|SPACE) [{directory} SLASH] {filename}". (Note well, if the hash digest creation is performed in text mode instead of binary mode, then there will be two space characters instead of a single space character and an asterisk.) For example:

To verify that a file was downloaded correctly or that it has not been tampered with:

Hash file trees sha1sum can only create checksums of one or multiple files inside a directory, but not of a directory tree, i.e. of subdirectories, sub-subdirectories, etc. and the files they contain. This is possible by using sha1sum in combination with the find command with the -exec option, or by piping the output from find into xargs. sha1deep can create checksums of a directory tree. To use sha1sum with find:

Likewise, piping the output from find into xargs yields the same output:

Related programs shasum is a Perl program to calculate any of SHA-1, 224, 256, 384, 512 hashes. It is part of the ActivePerl distribution. sha3sum is a similarly named program that calculates SHA-3, HAKE, RawSHAKE, and Keccak functions. The <hash>sum naming convention is also used by the BLAKE team with b2sum and b3sum, by the program tthsum, and many others. On FreeBSD and OpenBSD, the utilities are called md5, sha1, sha256, and sha512. These versions offer slightly different options and features. Additionally, FreeBSD offers the Skein family of message digests.

See also cksum md5sum md5deep GNU Core Utilities

References

External links sha1sum(1) – Linux User Commands Manual sha1sum for Windows announcement FreeBSD Manual Pages md5 OpenBSD General Commands Manual md5

Worked examples

Example 1 — a first encounter with Sha1sum

Start with the simplest possible case. Write down what Sha1sum claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Sha1sum before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Sha1sum ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Sha1sum

In research
Sha1sum appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Sha1sum in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Sha1sum is common in secondary-school and first-year university syllabi. It links to neighbouring topics Cryptographic software, Unix security-related software, so understanding it makes those chapters shorter.
In everyday life
Look for Sha1sum outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Sha1sum in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Sha1sum means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Sha1sum out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Sha1sum in simple terms?

sha1sum is a computer program that calculates and verifies SHA-1 hashes. It is commonly used to verify the integrity of files.

Why does Sha1sum matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Sha1sum?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Sha1sum.

Tags

  • Cryptographic software
  • Unix security-related software

Keep exploring