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
636
votes
47 answers

SHA-1 fingerprint of keystore certificate

Is the method for getting an SHA-1 fingerprint the same as the method of getting the fingerprint? Previously, I was running this command: It's not clear to me if the result I'm getting is the SHA-1 fingerprint. Can somebody clarify this?
user2208349
  • 7,429
  • 5
  • 26
  • 35
226
votes
9 answers

Hash collision in git

What would actually happen if I had a hash collision while using git? E.g. I manage to commit two files with the same sha1 checksum, would git notice it or corrupt one of the files? Could git be improved to live with that, or would I have to change…
Sec
  • 7,059
  • 6
  • 31
  • 58
194
votes
5 answers

Simple (non-secure) hash function for JavaScript?

Possible Duplicate: Generate a Hash from string in Javascript/jQuery Can anyone suggest a simple (i.e. tens of lines of code, not hundreds of lines) hash function written in (browser-compatible) JavaScript? Ideally I'd like something that, when…
mjs
  • 63,493
  • 27
  • 91
  • 122
182
votes
9 answers

Hashing a file in Python

I want python to read to the EOF so I can get an appropriate hash, whether it is sha1 or md5. Please help. Here is what I have so far: import hashlib inputFile = raw_input("Enter the name of the file:") openedFile = open(inputFile) readFile =…
user3358300
  • 1,919
  • 2
  • 13
  • 6
179
votes
13 answers

Java String to SHA1

I'm trying to make a simple String to SHA1 converter in Java and this is what I've got... public static String toSHA1(byte[] convertme) { MessageDigest md = null; try { md = MessageDigest.getInstance("SHA-1"); } …
Brian
  • 7,955
  • 16
  • 66
  • 107
172
votes
33 answers

Generate SHA-1 for Flutter/React-Native/Android-Native app

I'm trying to generate a SHA-1 for a Flutter app, for Android studio to support Google Sign in, but I don't know how to do that, I saw some posts that indicate to run a command, but there I need a jks file I guess, and flutter doesn't create…
Joseph Arriaza
  • 12,014
  • 21
  • 44
  • 63
164
votes
4 answers

How do I create a SHA1 hash in ruby?

SHA Hash functions
quackingduck
  • 5,845
  • 5
  • 29
  • 22
162
votes
7 answers

Storing SHA1 hash values in MySQL

I have a simple question which occured when I wanted to store the result of a SHA1 hash in a MySQL database: How long should the VARCHAR field be in which I store the hash's result?
niklasfi
  • 15,245
  • 7
  • 40
  • 54
155
votes
5 answers

How to generate random SHA1 hash to use as ID in node.js?

I am using this line to generate a sha1 id for node.js: crypto.createHash('sha1').digest('hex'); The problem is that it's returning the same id every time. Is it possible to have it generate a random id each time so I can use it as a database…
ajsie
  • 77,632
  • 106
  • 276
  • 381
155
votes
7 answers

Is SHA-1 secure for password storage?

Conclusion: SHA-1 is safe against preimage attacks, however it is easy to compute, which means it is easier to mount a bruteforce or dictionary attack. (The same is true for successors like SHA-256.) Depending on the circumstances, a hash function…
Tgr
  • 27,442
  • 12
  • 81
  • 118
146
votes
7 answers

Is calculating an MD5 hash less CPU intensive than SHA family functions?

Is calculating an MD5 hash less CPU intensive than SHA-1 or SHA-2 on "standard" laptop x86 hardware? I'm interested in general information, not specific to a certain chip. UPDATE: In my case, I'm interested in calculating the hash of a file. If…
Mick
  • 13,248
  • 9
  • 69
  • 119
144
votes
13 answers

How to assign a Git SHA1's to a file without Git?

As I understand it when Git assigns a SHA1 hash to a file this SHA1 is unique to the file based on its contents. As a result if a file moves from one repository to another the SHA1 for the file remains the same as its contents have not changed.…
git-noob
  • 5,757
  • 11
  • 34
  • 32
144
votes
7 answers

How to convert byte array to string in Go

[]byte to string raises an error. string([]byte[:n]) raises an error too. By the way, for example, sha1 value to string for filename. Does it need utf-8 or any other encoding set explicitly? Thanks!
lindsay show
  • 1,571
  • 2
  • 9
  • 6
141
votes
6 answers

How does Git compute file hashes?

The SHA1 hashes stored in the tree objects (as returned by git ls-tree) do not match the SHA1 hashes of the file content (as returned by sha1sum): $ git cat-file blob 4716ca912495c805b94a88ef6dc3fb4aff46bf3c |…
netvope
  • 7,647
  • 7
  • 32
  • 42
136
votes
11 answers

SHA1 vs md5 vs SHA256: which to use for a PHP login?

I'm making a php login, and I'm trying to decide whether to use SHA1 or Md5, or SHA256 which I read about in another stackoverflow article. Are any of them more secure than others? For SHA1/256, do I still use a salt? Also, is this a secure way to…
Tony Stark
  • 24,588
  • 41
  • 96
  • 113
1
2 3
99 100