Questions tagged [sha1]

SHA-1 is a cryptographic hash function designed by the U.S. Government as a Federal Information Processing Standard. Recently, collisions have been detected, meaning that SHA1 is becoming more vulnerable to attacks, and its use for protecting data is not recommended.

NOTE: Sha1 is no longer secure due to collisions being found. It is recommended you use or another hashing system like

In cryptography, SHA-1 is a cryptographic hash function designed by the National Security Agency (NSA) and published by the NIST as a U.S. Federal Information Processing Standard. SHA stands for Secure Hash Algorithm. The three SHA algorithms are structured differently and are distinguished as SHA-0, SHA-1, and SHA-2. SHA-1 is very similar to SHA-0, but corrects an error in the original SHA hash specification that led to significant weaknesses. The SHA-0 algorithm was not adopted by many applications. SHA-2 on the other hand significantly differs from the SHA-1 hash function.

SHA-1 is the most widely used of the existing SHA hash functions, and is employed in several widely-used security applications and protocols. In 2005, security flaws were identified in SHA-1, namely that a mathematical weakness might exist, indicating that a stronger hash function would be desirable. Although no successful attacks have yet been reported on the SHA-2 variants, they are algorithmically similar to SHA-1 and so efforts are underway to develop improved alternatives. A new hash standard, SHA-3, is currently under development — an ongoing NIST hash function competition is scheduled to end with the selection of a winning function in 2012.

References:

1825 questions
125
votes
20 answers

How to add SHA-1 to android application

I'm trying to create a dynamic link in Firebase, when I'm selecting the android app, it shows an error saying "Add SHA-1 to this android app", I've already added a credential, but I'm not sure how exactly do I "add SHA-1 to the app" How is this…
John Sardinha
  • 3,566
  • 6
  • 25
  • 55
121
votes
5 answers

HMAC-SHA1 in bash

Is there a bash script to generate a HMAC-SHA1 hash? I'm looking for something equivalent to the following PHP code: hash_hmac("sha1", "value", "key");
Mark
  • 67,098
  • 47
  • 117
  • 162
111
votes
12 answers

How can I get the MD5 fingerprint from Java's keytool, not only SHA-1?

As I want to use Google maps in my application, I need the debug certificates' MD5 fingerprint. I tried following.: (Here I copied the debug.keystore file from C:\Documents and Settings\Administrator.android in bin folder) C:\Program…
Prachi Kshirsagar
  • 1,141
  • 2
  • 9
  • 5
106
votes
6 answers

Hashing with SHA1 Algorithm in C#

I want to hash given byte[] array with using SHA1 Algorithm with the use of SHA1Managed. The byte[] hash will come from unit test. Expected hash is 0d71ee4472658cd5874c5578410a9d8611fc9aef (case sensitive). How can I achieve this? public string…
Merve Kaya
  • 1,219
  • 2
  • 10
  • 16
82
votes
5 answers

Is it possible to get identical SHA1 hash?

Given two different strings S1 and S2 (S1 != S2) is it possible that: SHA1(S1) == SHA1(S2) is True? If yes - with what probability? If not - why not? Is there a upper bound on the length of a input string, for which the probability of getting…
Andriy Drozdyuk
  • 58,435
  • 50
  • 171
  • 272
76
votes
10 answers

Get SHA1 fingerprint certificate in Android Studio for Google Maps

I want to get the SHA1 key from Android Studio on a Mac. From Eclipse it's simple, but I can't get this in Android Studio. I have checked similar questions but didn't get any way to get that in MAC. The SHA1 is different for signed and unsigned APK.…
arslan haktic
  • 4,348
  • 4
  • 22
  • 35
75
votes
11 answers

How to SHA1 hash a string in Android?

In Objective C I've been using the following code to hash a string: -(NSString *) sha1:(NSString*)stringToHash { const char *cStr = [stringToHash UTF8String]; unsigned char result[20]; CC_SHA1( cStr, strlen(cStr), result ); …
Martin
  • 7,190
  • 9
  • 40
  • 48
73
votes
3 answers

Probability of SHA1 collisions

Given a set of 100 different strings of equal length, how can you quantify the probability that a SHA1 digest collision for the strings is unlikely... ?
eastafri
  • 2,186
  • 2
  • 23
  • 34
72
votes
8 answers

How to hash NSString with SHA1 in Swift?

In objective-c it looks like this: #include @implementation NSString (reverse) -(NSString*)sha1 { NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding]; uint8_t digest[CC_SHA1_DIGEST_LENGTH]; CC_SHA1(data.bytes,…
imike
  • 5,515
  • 2
  • 37
  • 44
70
votes
4 answers

How to get (only) author name or email in git given SHA1?

I would like to check for author's e-mail and name, surname to verify who's pushing to my repo. Is there any way that I can come up with a command in git to show commiter's name/e-mail given only SHA1 of the commit? This is what I came up with but…
Patryk
  • 22,602
  • 44
  • 128
  • 244
70
votes
10 answers

How can I pass git SHA1 to compiler as definition using cmake?

In a Makefile this would be done with something like: g++ -DGIT_SHA1="`git log -1 | head -n 1`" ... This is very useful, because the binary knows exact commit SHA1 so it can dump it in case of segfault. How can I achieve the same with CMake?
Łukasz Lew
  • 48,526
  • 41
  • 139
  • 208
65
votes
16 answers

Java calculate hex representation of a SHA-1 digest of a String

I'm storing the user password on the db as a sha1 hash. Unfortunately I'm getting strange answers. I'm storing the string as this: MessageDigest cript = MessageDigest.getInstance("SHA-1"); cript.reset(); …
Marcos Roriz Junior
  • 4,076
  • 11
  • 51
  • 76
65
votes
4 answers

How do I do a SHA1 File Checksum in C#?

How do I use the SHA1CryptoServiceProvider() on a file to create a SHA1 Checksum of the file?
Firesteel
  • 689
  • 1
  • 6
  • 3
63
votes
8 answers

Objective-C sample code for HMAC-SHA1

I need to generate HMAC-SHA1 in Objective C. But i didnt find anything that works. I tried with CommonCrypto, using CCHMAC, but didnt works. I need to generate a hmac and after generate HOTP number. Somebody have any example code in Objective C or…
Helena
  • 741
  • 1
  • 6
  • 5
62
votes
2 answers

What checksum algorithm should I use?

I'm building a system which needs to be able to find if blobs of bytes have been updated. Rather than storing the whole blob (they can be up to 5MBs), I'm thinking I should compute a checksum of it, store this and compute the same checksum a little…
Julien Genestoux
  • 31,046
  • 20
  • 66
  • 93