Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

sha1sum

From Wikipedia, the free encyclopedia
SHA1 is a broken and proven vulnerable algorithm. The article may be rewritten withSHA256 (unbroken, as of Jan 2022), or some other safer alternative as the title and the main focus.
This article has multiple issues. Please helpimprove it or discuss these issues on thetalk page.(Learn how and when to remove these messages)
This articlemay be too technical for most readers to understand. Pleasehelp improve it tomake it understandable to non-experts, without removing the technical details.(July 2021) (Learn how and when to remove this message)
This articleprovides insufficient context for those unfamiliar with the subject. Please helpimprove the article byproviding more context for the reader.(July 2021) (Learn how and when to remove this message)
(Learn how and when to remove this message)
Software that calculates and verifies SHA-1 hashes

sha1sum is acomputer program that calculates and verifiesSHA-1hashes. It is commonly used to verify the integrity of files. It (or a variant) is installed by default on mostLinux distributions. Typically distributed alongsidesha1sum aresha224sum,sha256sum,sha384sum andsha512sum, which use a specificSHA-2 hash function andb2sum,[1] which uses theBLAKE2 cryptographic hash function.

The SHA-1 variants areproven vulnerable tocollision attacks, and users should instead use, for example, a SHA-2 variant such assha256sum or theBLAKE2 variantb2sum to prevent tampering by an adversary.[2][3]

It is included inGNU Core Utilities,[4]Busybox (excludingb2sum),[5] andToybox (excludingb2sum).[6] Ports to a wide variety of systems are available, includingMicrosoft Windows.

Examples

[edit]

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

$sha1sumfilename[filename2]...>SHA1SUM

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

$sha1sum--binarymy-zip.tar.gz>my-zip.tar.gz.sha1

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:

$sha1sum-bmy-zip.tar.gzd5db29cd03a2ed055086cef9c31c252b4587d6d0 *my-zip.tar.gz$sha1sum-bsubdir/filename255086cef9c87d6d031cd5db29cd03a2ed0252b45 *subdir/filename2

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

$sha1sum-cSHA1SUMfilename: OKfilename2: OK$sha1sum-cmy-zip.tar.gz.sha1my-zip.tar.gz: OK

Hash file trees

[edit]

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 usingsha1sum in combination with thefind command with the-exec option, or bypiping the output fromfind intoxargs.sha1deep can create checksums of a directory tree.

To usesha1sum withfind:

$finds_*-typef-execsha1sum'{}'\;65c23f142ff6bcfdddeccebc0e5e63c41c9c1721  s_1/file_s11d3d59905cf5fc930cd4bf5b709d5ffdbaa9443b2  s_2/file_s215590e00ea904568199b86aee4b770fb1b5645ab8  s_a/file_02

Likewise, piping the output fromfind intoxargs yields the same output:

$finds_*-typef|xargssha1sum65c23f142ff6bcfdddeccebc0e5e63c41c9c1721  s_1/file_s11d3d59905cf5fc930cd4bf5b709d5ffdbaa9443b2  s_2/file_s215590e00ea904568199b86aee4b770fb1b5645ab8  s_a/file_02

Related programs

[edit]
  • shasum is aPerl program to calculate any of SHA-1, 224, 256, 384, 512 hashes.[7] It is part of theActivePerl distribution.
  • sha3sum is a similarly named program that calculatesSHA-3, HAKE, RawSHAKE, andKeccak functions.[8]
  • The<hash>sum naming convention is also used by theBLAKE team withb2sum andb3sum, by the programtthsum, and many others.
  • OnFreeBSD andOpenBSD, the utilities are calledmd5,sha1,sha256, andsha512. These versions offer slightly different options and features. Additionally, FreeBSD offers theSkein family of message digests.[9]

See also

[edit]

References

[edit]
  1. ^"b2sum source code in GNU coreutils".GNU coreutils mirror at GitHub. Retrieved29 Jan 2022.
  2. ^Bruce Schneier."Cryptanalysis of SHA-1". Schneier on Security.
  3. ^"Announcing the first SHA1 collision".
  4. ^"Sha1sum invocation (GNU Coreutils 9.0)".
  5. ^"Mirror/Busybox".GitHub. 26 October 2021.
  6. ^"Landley/Toybox".GitHub. 26 October 2021.
  7. ^shasum(1) – Linux General CommandsManual
  8. ^sha3sum(1) – Linux General CommandsManual
  9. ^md5(1) – FreeBSD General CommandsManual

External links

[edit]
File system
Text utilities
Shell utilities
Retrieved from "https://en.wikipedia.org/w/index.php?title=Sha1sum&oldid=1270010433"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp