Questions tagged [sha]

SHA (Secure Hash Algorithm) is a family of digest algorithms (i.e. cryptographic hashes), i.e. checksum functions that are hard to forge. The recommended digest algorithms these days are SHA-1 and SHA-2 (which covers both SHA-256 and SHA-512). MD5 is a deprecated alternative.

SHA is a family of cryptographic hash functions (i.e. cryptographic digests). That is, they are checksum functions (producing a fixed-size output for an (almost) arbitrary-sized input), with no known way to find two inputs with the same checksum or to recover the input given the checksum.

The SHA algorithms are specified by the U.S. standard body NIST's publication FIPS-180. There have been several versions of SHA; both SHA-1 and SHA-2 are currently in widespread use:

  • SHA-0: withdrawn in favor of SHA-1 due to an undisclosed flaw
  • SHA-1 : a widely-used algorithm with a 160-bit result, published in 1993. SHA-1 is currently deprecated in favor of SHA-2, although it is still approved for many official uses and no serious flaw is known.
  • SHA-2 : a family of four similar algorithms with different output sizes: SHA-256, SHA-512, and the less common variants SHA-224 and SHA-384. It was published in 2002.
  • SHA-3 : the future successor of SHA-1 and SHA-2, which is scheduled to be selected by NIST in 2012 amongst candidates (the selection is now down to 5 competitors).

MD5 is an earlier cryptographic digest algorithm, now deprecated because collisions have been found, but still used in legacy systems.

1182 questions
234
votes
5 answers

How much of a git sha is *generally* considered necessary to uniquely identify a change in a given codebase?

If you're going to build, say, a directory structure where a directory is named for a commit in a Git repository, and you want it to be short enough to make your eyes not bleed, but long enough that the chance of it colliding would be negligible,…
222
votes
3 answers

Is it safe to ignore the possibility of SHA collisions in practice?

Let's say we have a billion unique images, one megabyte each. We calculate the SHA-256 hash for the contents of each file. The possibility of collision depends on: the number of files the size of the single file How far can we go ignoring this…
Hristo Hristov
  • 3,521
  • 3
  • 22
  • 36
161
votes
1 answer

Where does Git store the SHA1 of the commit for a submodule?

I know that when you add a submodule to a git repository it tracks a particular commit of that submodule referenced by its sha1. I'm trying to find where this sha1 value is stored. The .gitmodules and .git/config files only show the paths for the…
Abizern
  • 129,329
  • 36
  • 198
  • 252
116
votes
12 answers

php mysqli_connect: authentication method unknown to the client [caching_sha2_password]

I am using php mysqli_connect for login to a MySQL database (all on localhost)
Guti_Haz
  • 1,878
  • 2
  • 12
  • 13
95
votes
4 answers

Why doesn't Git use more modern SHA?

I read about that Git uses SHA-1 digest as an ID for a revision. Why does it not use a more modern version of SHA?
qazwsx
  • 21,470
  • 25
  • 65
  • 97
80
votes
8 answers

Method not found using DigestUtils in Android

I am trying to use the library DigestUtils in Android 2.3.1 using JDK 1.6, however I get the following error when executing the app: Could not find method org.apache.commons.codec.binary.Hex.encodeHexString, referenced from method…
Caumons
  • 8,153
  • 9
  • 60
  • 77
61
votes
5 answers

cherry-pick a commit and keep original SHA code

I would like to cherry-pick a commit on a fetched remote while keeping it's original SHA commit code (my current branch is based on this remote which I resetted to a previous state).
blameless75
  • 1,790
  • 2
  • 17
  • 14
60
votes
3 answers

How does Git(Hub) handle possible collisions from short SHAs?

Both Git and GitHub display short versions of SHAs -- just the first 7 characters instead of all 40 -- and both Git and GitHub support taking these short SHAs as arguments. E.g. git show 962a9e8 E.g.…
Aseem Kishore
  • 9,137
  • 8
  • 44
  • 55
56
votes
3 answers

How long to brute force a salted SHA-512 hash? (salt provided)

Here is an algorithm in Java: public String getHash(String password, String salt) throws Exception { String input = password + salt; MessageDigest md = MessageDigest.getInstance(SHA-512); byte[] out = md.digest(input.getBytes()); …
timothyjc
  • 2,098
  • 3
  • 28
  • 52
56
votes
3 answers

Creating user with encrypted password in PostgreSQL

Is it possible to create a user in PostgreSQL without providing the plain text password (ideally, I would like to be able to create a user providing only its password crypted with sha-256) ? What I would like to do is to create a user with something…
Martin
  • 1,592
  • 1
  • 12
  • 17
55
votes
1 answer

How to cherry-pick the last sha from another branch in Git with 1 command?

I find myself doing this a lot when cherry-picking a commit from another branch. $ git log -1 another_branch commit // copy $ git cherry-pick Can I do all of this in one command, if so, what is it?
FoxyGio
  • 595
  • 1
  • 4
  • 5
54
votes
6 answers

SHA1 VS RSA: what's the difference between them?

What are the differences between SHA1 and RSA? Are they just different algorithms or are they fundamentally (i.e. used for different things) different on some level.
Ted Smith
  • 8,837
  • 14
  • 48
  • 52
52
votes
4 answers

How can I calculate the SHA-256 hash of a string in Android?

I'm trying to get the SHA256 of a string in Android. Here is the PHP code that I want to match: echo bin2hex(mhash(MHASH_SHA256,"asdf")); //outputs "f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b" Now, in Java, I'm trying to do…
Eamorr
  • 9,308
  • 32
  • 117
  • 200
47
votes
4 answers

Suppress Firefox/Firebug SHA-1 warning

I use Firebug for web development. Since version Firefox 37 I see the following annoying message in my console: This site makes use of a SHA-1 Certificate; it's recommended you use certificates with signature algorithms that use hash functions…
Sergey Kravchenko
  • 957
  • 1
  • 7
  • 19
42
votes
6 answers

Hashing in SHA512 using a salt? - Python

I have been looking through ths hashlib documentation but haven't found anything talking about using salt when hashing data. Help would be great.
RadiantHex
  • 22,589
  • 43
  • 141
  • 236
1
2 3
78 79