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.
sha1
1,840
questions
644
votes
48
answers
1.1m
views
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 ...
241
votes
9
answers
65k
views
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 ...
200
votes
5
answers
264k
views
Simple (non-secure) hash function for JavaScript? [duplicate]
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) ...
198
votes
9
answers
231k
views
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 ...
188
votes
33
answers
408k
views
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 ...
183
votes
13
answers
316k
views
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 = ...
165
votes
4
answers
93k
views
How do I create a SHA1 hash in ruby?
SHA Hash functions
162
votes
7
answers
120k
views
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?
161
votes
7
answers
374k
views
How to convert byte array to string in Go [duplicate]
[]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!
157
votes
6
answers
126k
views
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 ...
155
votes
7
answers
64k
views
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.) ...
150
votes
7
answers
136k
views
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 ...
144
votes
13
answers
25k
views
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 ...
143
votes
7
answers
52k
views
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 ...
136
votes
11
answers
165k
views
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 ...
127
votes
20
answers
231k
views
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 ...
121
votes
5
answers
112k
views
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");
112
votes
13
answers
88k
views
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\...
107
votes
6
answers
194k
views
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 ...
82
votes
5
answers
62k
views
Is it possible to get identical SHA1 hash? [duplicate]
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 ...
76
votes
10
answers
132k
views
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.
...
76
votes
11
answers
117k
views
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];
...
75
votes
3
answers
55k
views
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... ?
75
votes
4
answers
78k
views
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 ...
72
votes
8
answers
45k
views
How to hash NSString with SHA1 in Swift?
In objective-c it looks like this:
#include <sys/xattr.h>
@implementation NSString (reverse)
-(NSString*)sha1
{
NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding];
uint8_t ...
71
votes
10
answers
36k
views
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 ...
65
votes
16
answers
105k
views
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");
...
65
votes
4
answers
54k
views
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?
63
votes
8
answers
59k
views
Objective-C sample code for HMAC-SHA1 [closed]
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.
...
63
votes
2
answers
50k
views
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, ...
62
votes
5
answers
12k
views
Why does git hash-object return a different hash than openssl sha1?
Context: I downloaded a file (Audirvana 0.7.1.zip) from code.google to my Macbook Pro (Mac OS X 10.6.6).
I wanted to verify the checksum, which for that particular file is posted as ...
61
votes
5
answers
73k
views
HMAC-SHA1: How to do it properly in Java?
I'm hashing some values using HMAC-SHA1, using the following code in Java:
public static String hmacSha1(String value, String key) {
try {
// Get an hmac_sha1 key from the raw key bytes
...
59
votes
8
answers
101k
views
SHA1 Key for DEBUG & RELEASE ANDROID STUDIO MAC , How to generate SHA1 Release Keys in Mac?
How do I get my SHA1 Keys for debug and release using android studio on a mac?
(These are required for Google API Keys)
58
votes
8
answers
81k
views
Implementation HMAC-SHA1 in python
I am trying to use the OAuth of a website, which requires the signature method to be 'HMAC-SHA1' only.
I am wondering how to implement this in Python?
56
votes
4
answers
58k
views
Git - finding the SHA1 of an individual file in the index
I've added a file to the 'index' with:
git add myfile.java
How do I find out the SHA1 of this file?
56
votes
8
answers
63k
views
Compute SHA-1 of byte array
I'm looking for a way of getting an SHA-1 checksum with a Java byte array as the message.
Should I use a third party tool or is there something built in to the JVM that can help?
54
votes
4
answers
48k
views
Google Maps API for Android, getting SHA1 cert instead of MD5
When I try to get the MD5 fingerprint using keytool, I get a SHA1 fingerprint instead and the Google Maps doesn't recognize it. How do I get the MD5 fingerprint?
53
votes
6
answers
59k
views
A Regex to match a SHA1
I'm trying to match SHA1's in generic text with a regular expression.
Ideally I want to avoid matching words.
It's safe to say that full SHA1's have a distinctive pattern (they're long and a ...
52
votes
2
answers
58k
views
How to generate an HMAC in Java equivalent to a Python example?
I'm looking at implementing an app getting Twitter authorization via Oauth in Java. The first step is getting a request token. Here is a Python example for app engine.
To test my code, I am running ...
51
votes
5
answers
130k
views
Check if my SSL Certificate is SHA1 or SHA2
I have tried to find the answer to this but I couldn't find an answer...
How do I check if my SSL Certificate is using SHA1 or SHA2?
Reason I ask is because it might have to do with the certificate ...
50
votes
5
answers
15k
views
What are the chances that two messages have the same MD5 digest and the same SHA1 digest?
Given two different messages, A and B (maybe 20-80 characters of text, if size matters at all), what is the probability that the MD5 digest of A is the same as the MD5 digest of B and the SHA1 digest ...
48
votes
6
answers
27k
views
Git - finding a filename from a SHA1
I added a file to the index with:
git add somefile.txt
I then got the SHA1 for this file with:
git hash-object somefile.txt
I now have a SHA1 and I would like to retrieve the filename of the ...
46
votes
6
answers
65k
views
Why is a SHA-1 Hash 40 characters long if it is only 160 bit?
The title of the question says it all. I have been researching SHA-1 and most places I see it being 40 Hex Characters long which to me is 640bit. Could it not be represented just as well with only 10 ...
44
votes
3
answers
41k
views
How to installing sha1sum in MAC OS?
Problem:
To get the sha1sum value of a file in MAC OS i run the following command
sha1sum file_name
The error I got is following
perl version 5.18.2 can't run /usr/bin/sha1sum. Try the ...
43
votes
7
answers
41k
views
Creating SHA1 Hash from NSString
How can I create a SHA1 from a NSString.
Let's say the NSString is set up as:
NSString *message = @"Message";
I can use PHP to create a SHA1 hash with sha($message). But unfortunately it doesn't ...
43
votes
11
answers
112k
views
Is it possible to reverse a SHA-1 hash?
Is it possible to reverse a SHA-1?
I'm thinking about using a SHA-1 to create a simple lightweight system to authenticate a small embedded system that communicates over an unencrypted connection.
Let'...
43
votes
1
answer
48k
views
RSA signature size?
I would like to know what is the length of RSA signature ? Is it always the same size as the RSA key size like if the key size is 1024 then RSA signature is 128 bytes , if the key size is 512 bits ...
41
votes
3
answers
52k
views
Why use SHA1 for hashing secrets when SHA-512 is more secure?
I don't mean for this to be a debate, but I'm trying to understand the technical rationale behind why so many apps use SHA1 for hashing secrets, when SHA512 is more secure. Perhaps it's simply for ...
40
votes
6
answers
38k
views
Is there an equivalent to SHA1() in MS-SQL?
Converting a couple stored procedures from MySQL to Microsoft SQL server. Everything is going well, except one procedure used the MySQL SHA1() function. I cannot seem to find an equivalent to this in ...
40
votes
3
answers
124k
views
Password hash function for Excel VBA
I need a function written in Excel VBA that will hash passwords using a standard algorithm such as SHA-1. Something with a simple interface like:
Public Function CreateHash(Value As String) As ...