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.

1323 questions
25
votes
1 answer

Probability of hash collision

I am looking for some precise math on the likelihood of collisions for MD5, SHA1, and SHA256 based on the birthday paradox. I am looking for something like a graph that says "If you have 10^8 keys, this is the probability. If you have 10^13 keys,…
Dark Nebula
  • 403
  • 1
  • 4
  • 6
24
votes
3 answers

SHA 256 pseuedocode?

I've been trying to work out how SHA-256 works. One thing I've been doing for other algorithms is I've worked out a sort of step by step pseudocode function for the algorithm. I've tried to do the same for SHA256 but thus far I'm having quite a bit…
codelion
  • 319
  • 1
  • 2
  • 11
23
votes
2 answers

sha256 function in SQL Server

Is there a built-in sha256 function in SQL Server? I can't find a sha256 T-SQL function source code either. Anyone who has an alternative?
setzamora
  • 3,560
  • 6
  • 34
  • 48
22
votes
1 answer

Compute SHA1 of Strings in python

I have a file which contains a lot of Strings. I am trying to compute SHA1 hashes of these strings individually and store those import hashlib inp = open("inp.txt" , "r") outputhash = open("outputhashes.txt", "w") for eachpwd in inp: sha_1 =…
kidd0
  • 731
  • 2
  • 8
  • 25
21
votes
5 answers

Improve password hashing with a random salt

I'm starting a website and I'm trying to decide how to encrypt user passwords to store them in a SQL database. I realize that using a simple md5(password) is very unsecured. I'm considering using a sha512(password.salt), and I have been researching…
Tchoupi
  • 14,560
  • 5
  • 37
  • 71
20
votes
4 answers

Is it okay to truncate a SHA256 hash to 128 bits?

MD5 and SHA-1 hashes have weaknesses against collision attacks. SHA256 does not but it outputs 256 bits. Can I safely take the first or last 128 bits and use that as the hash? I know it will be weaker (because it has less bits) but otherwise will it…
Sunny Hirai
  • 201
  • 1
  • 2
  • 3
20
votes
4 answers

How do I check if my SSL Certificate is SHA1 or SHA2 on the commandline

How do I check if my SSL Certificate is using SHA1 or SHA2, from the commandline? And yes, i this is similar to this, but i need a cli-tool and i want to understand how it is done.
20
votes
3 answers

Is it possible to decrypt SHA1

Is it possible to decrypt(retain the actual string) the password which is saved in db using SHA1 algorithm. Example:If password is "password" and it is stored in db as "sha1$4fb4c$2bc693f8a86e2d87f757c382a32e3d50fc945b24",is any chance to retain the…
user2725407
  • 400
  • 1
  • 4
  • 16
19
votes
2 answers

How can I compare a file's SHA256 hash in PowerShell to a known value?

If I've downloaded a file with a known SHA256 hash, how can I use PowerShell to check that the file matches the expected hash?
mac
  • 3,137
  • 1
  • 28
  • 42
19
votes
3 answers

6 Character Short Hash Algorithm

My goal is to generate a short Hash string of 6 characters (possibly containing characters [A-Z][a-z][0-9]) for a string which is 42 case-insensitive alphanumeric characters in length. Uniqueness is the key requirement. Security or performance is…
Isuru
  • 594
  • 1
  • 5
  • 19
18
votes
3 answers

How to get SHA1 fingerprints from p12 certificate?

In order to get the keys of my Android project, Google requires SHA1 fingerprint. Offered this command: keytool-list-v-keystore mystore.keystore I went through different options, but always in an error Illegal option: Files keytool:-list [OPTION]…
Astraport
  • 1,239
  • 4
  • 20
  • 40
17
votes
3 answers

Converting a unique seed string into a random, yet deterministic, float value in Ruby

I'm having a hard time with this, conceptually. Basically, I need to accept some arbitrary unique string, and be able to convert that to a normalized float value. What the output float value is doesn't really matter, so long as the same string…
Alex Wayne
  • 178,991
  • 47
  • 309
  • 337
17
votes
5 answers

How to calculate sha 512 hash properly in .NET 6

In .NET 6 code from How can I SHA512 a string in C#? var data = Encoding.UTF8.GetBytes("key"); byte[] hash; using (SHA512 shaM = new SHA512Managed()) hash = shaM.ComputeHash(data); Throws warning Warning SYSLIB0021 'SHA512Managed' is…
Andrus
  • 26,339
  • 60
  • 204
  • 378
17
votes
3 answers

Securing data in the google app engine datastore

Our google app engine app stores a fair amount of personally identifying information (email, ssn, etc) to identify users. I'm looking for advice as to how to secure that data. My current strategy Store the sensitive data in two forms: Hashed -…
Rob Boyle
  • 430
  • 3
  • 9
16
votes
3 answers

How does Apple's codesign utility decide which SHA algorithm(s) to sign a shared library with?

First, a little background: I'm investigating why my company's MacOS/X application (which by all accounts appears to be correctly signed; it runs fine under MacOS/X 10.11.x and 10.12.x; Gatekeeper is fine with it on all MacOS versions; "spctl…
Jeremy Friesner
  • 70,199
  • 15
  • 131
  • 234
1 2
3
88 89