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.
1,334
questions
303
votes
5
answers
110k
views
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 ...
268
votes
3
answers
123k
views
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 ...
201
votes
2
answers
48k
views
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 ...
162
votes
19
answers
322k
views
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)
<?php
//DEFINE ('DB_USER', 'user2');
//DEFINE ('DB_PASSWORD', 'pass2');
DEFINE ('DB_USER', 'user1');
DEFINE ('...
102
votes
4
answers
28k
views
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?
92
votes
5
answers
58k
views
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).
87
votes
8
answers
45k
views
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....
75
votes
1
answer
22k
views
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 <commit_sha>
// copy <commit_sha>
$ git cherry-pick <commit_sha>
...
68
votes
3
answers
17k
views
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....
67
votes
5
answers
129k
views
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 ...
63
votes
7
answers
74k
views
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.
59
votes
3
answers
120k
views
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);
...
57
votes
5
answers
72k
views
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 "...
53
votes
11
answers
89k
views
Android Studio only gives me SHA1, I need SHA256
I want to use assetlinks.json for appindexing.
I am supposed to use a SHA256 fingerprint, but when I print out the signingReport in Android Studio, I only have SHA1.
Can I use SHA1? If not, how can I ...
50
votes
1
answer
40k
views
What pool of characters do MD5 and SHA have?
Does MD5 and SHA only contain alphanumeric characters? (i.e., from A to Z and 0 to 9, or do they exclude some characters?)
46
votes
4
answers
21k
views
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 ...
45
votes
6
answers
86k
views
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.
44
votes
3
answers
27k
views
Why does git commit --amend change the hash even if I don't make any changes?
Why does the SHA-1 hash of my latest commit change even if I don't make any changes to the commit (message, files) after running git commit --amend?
Say I run the following at the command line.
cd ~/...
40
votes
4
answers
33k
views
Does every Android phone support SHA-256
So reading this post: How can I calculate the SHA-256 hash of a string in Android?
and the docs: http://developer.android.com/reference/java/security/MessageDigest.html
I'm curious; which phones ...
40
votes
4
answers
27k
views
How to find a Github file 's SHA blob
I'm using this API to update a file on my repo, it requires me to have a valid SHA blob for a file that I want to update:
http://developer.github.com/v3/repos/contents/
How do I find the SHA blob ...
38
votes
3
answers
14k
views
Compute SHA256 Hash in Android/Java and C#
I am trying to generate a SHA256 hash in android, that I then pass to an ASP.NET Web API web service and compare the hash there. As such, I need to construct a hash in Android, that given the same ...
35
votes
4
answers
38k
views
How to Generate an MD5 hash in Kotlin? [closed]
Generate MD5 hash of a string using standard library in Kotlin?
I have tried below mention code
import java.math.BigInteger
import java.security.MessageDigest
fun md5(input:String): String {
val ...
34
votes
4
answers
13k
views
Why does Zipping the same content twice gives two files with different SHA1?
I have run into a strange problem with git and zip files. My build script takes a bunch of documentation html pages and zips them into a docs.zip I then check this file into git.
The problem I am ...
33
votes
3
answers
31k
views
Java: How to create SHA-1 for a file?
What is the best way to create a SHA-1 for a very large file in pure Java6? How to implement this method:
public abstract String createSha1(java.io.File file);
31
votes
7
answers
26k
views
Create SHA-256 hash from a Blob/File in javascript
I need to create a SHA-256 digest from a file (~6MB) inside the browser. The only way that I've managed to do it so far was like this:
var reader = new FileReader();
reader.onload = function() {
//...
30
votes
3
answers
29k
views
JWT (JSON Web Token) in PHP without using 3rd-party library. How to sign?
There are a few libraries for implementing JSON Web Tokens (JWT) in PHP, such as php-jwt. I am writing my own, very small and simple class but cannot figure out why my signature fails validation here ...
30
votes
4
answers
20k
views
Are there in x86 any instructions to accelerate SHA (SHA1/2/256/512) encoding?
An example, in x86 are Instruction Set to hardware acceleration AES. But are there in x86 any instructions to accelerate SHA (SHA1/2/256/512) encoding, and what library is the fastet to encoding SHA ...
28
votes
5
answers
21k
views
When generating a SHA256 / 512 hash, is there a minimum 'safe' amount of data to hash?
I have heard that when creating a hash, it's possible that if small files or amounts of data are used, the resulting hash is more likely to suffer from a collision. If that is true, is there a minimum ...
27
votes
4
answers
31k
views
When should I use SHA-1 and when should I use SHA-2?
In my c# application, I'm using RSA to sign files before being uploaded on the database of my company by the person who is uploading and here I have to choose SHA-1 or SHA-2 for computing the hash.
As ...
27
votes
2
answers
11k
views
How to update Homebrew SHA256?
This seems like a very noob question but I can't find an answer anywhere!
I'm very new to developing packages for Homebrew but when I edit my formula and come to update my package I get the following ...
25
votes
1
answer
33k
views
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 ...
24
votes
3
answers
40k
views
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 ...
23
votes
2
answers
88k
views
sha256 function in SQL Server [duplicate]
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?
23
votes
1
answer
32k
views
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("...
22
votes
2
answers
32k
views
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?
21
votes
5
answers
3k
views
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 ...
20
votes
4
answers
33k
views
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
150k
views
Is it possible to decrypt SHA1 [duplicate]
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$...
20
votes
5
answers
13k
views
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);
...
20
votes
4
answers
13k
views
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 ...
19
votes
3
answers
32k
views
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 ...
19
votes
3
answers
21k
views
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 ...
17
votes
3
answers
7k
views
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 ...
17
votes
3
answers
4k
views
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
...
16
votes
1
answer
7k
views
Why does SHA1.ComputeHash fail under high load with many threads?
I'm seeing an issue with some code I maintain. The code below has a private static SHA1 member (which is an IDisposable but since it's static, it should never get finalized). However, under stress ...
16
votes
3
answers
12k
views
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 ...
15
votes
4
answers
18k
views
How to correctly generate SHA-256 checksum for a string in scala?
I need to generate an SHA-256 checksum from a string that will be sent as a get param.
If found this link to generate the checksum.
Genrating the checksum like so:
val digest = MessageDigest....
15
votes
3
answers
56k
views
get SHA256 hash of public key
I have a certificate mycert.pem . I got the public key of the certificate by command:
openssl x509 -pubkey -noout -in mycert.pem > pubkey.pem
How can I get the SHA256 hash of the public key?
15
votes
7
answers
20k
views
How do I convert password hashing from MD5 to SHA?
I've got an old application that has user passwords stored in the database with an MD5 hash. I'd like to replace this with something in the SHA-2 family.
I've thought of two possible ways to ...
14
votes
5
answers
17k
views
Creating signed URLs for Google Cloud Storage using NodeJS
I'm trying to create a signature for a privately stored file in Google Cloud Storage; so that I can distribute a time-limited link.
Currently doing this and it makes a signature that's too short ... ...