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
-2
votes
1 answer

Implementation of SHA-1 yields different hashes than the `java.security` implementation

I am trying to implement the SHA-1 algorithm in Java 11, and while testing the hashing algorithm I get different hashes than when hashing with the java.security implementation of SHA-1. The pseudocode I attempted to follow can be found on…
oranji
  • 41
  • 1
  • 8
-2
votes
1 answer

Hashing SHA-256 for C# and Java

I needed to generate the hash in Java and then check it in C#. How to get the same output from these two algorithms when converting back to a string? ------------C#------------ ? ------------Java------------ public static String encrypt(String…
Anh Trung
  • 21
  • 7
-2
votes
1 answer

How to validate dates in Hash format in MySQL or C++

I need to validate dates in Hash (SHA256) format in MySQL or C++. For example: date1 < date2 or date1 > date2. I have this query in MySQL: SELECT SHA1(CURDATE()) -->'2017-09-06' and: SELECT SHA1('2017-09-06') -->…
-2
votes
1 answer

Obfuscation and SHAs?

I'm trying to determine whether it's possible to utilize SHAs for obfuscating and still maintain a decent/full amount of functionality. I'm asking because I can't find anything pertaining to SHAs being used for obfuscating real run-time codes. Every…
curious
  • 1
  • 2
-2
votes
3 answers

Convert SHA-1 string to plain text java

I tried to search this but surprisingly could not find any results of converting SHA-1 generated string back to normal string. I hash a string to SHA-1 and then send it to some other device where this SHA-1 generated string should be unhashed and…
unrealsoul007
  • 3,809
  • 1
  • 17
  • 33
-2
votes
3 answers

Object Obect array Json.stringify string array

I had a object object array which i used JSON.stringify() on i can now see what's in my array but when i do arr[0] etc it only outputs one letter. arr = {"hello":"yes","because":"no"} arr[0] =h I want it to output the whole of the value not just…
-2
votes
1 answer

How to choose the best hashing algorithm when taking into account collisions' rate and speed of hash generation?

If I have a CSS file that is generated dynamically, which function should I use to generate a short identifying string for the whole file content? md5 or crc32 ? other?
Alex
  • 66,732
  • 177
  • 439
  • 641
-2
votes
2 answers

Key size of SHA512 hashing algorithm

What is the key size of the SHA512 hashing algorithm? I know that the final message digest is 512 bits. I would like to know what key size it uses. Thank you very much :)
Matthew
  • 4,477
  • 21
  • 70
  • 93
-2
votes
2 answers

Java Generate Unique Surrogate alphanumeric key based on text

I wanted to generate a unique key based on few columns(one of them is the search word....so the length can very long). The volume of records is around 6 million. I have used MD5 and generated a 32-character alphanumeric string. How confident can we…
rahul
  • 1,423
  • 3
  • 18
  • 28
-2
votes
3 answers

Decrypt SHA encrypted string

I have encrypted a string using the above code. public String encrypt(String generatedKey) { try { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(generatedKey.getBytes("UTF-8")); …
Gapchoos
  • 1,422
  • 5
  • 20
  • 40
-2
votes
1 answer

I'm using MD5 to hash passwords. When should I jump to the next thing? SHA-3?

On the 2nd of October NIST decided that SHA-3 is the new standard hashing algorithm. Should MD5 users start migrating to SHA-3? To something else (see below why SHA-3 is not recommended)? bcrypt? Why Not {MD5, SHA1, SHA256, SHA512, SHA-3,…
John Assymptoth
  • 8,227
  • 12
  • 49
  • 68
-3
votes
1 answer

How do I take the first 4 bytes of SHA256 in Rust?

How do I elegantly take first 4 bytes of SHA256 in Rust? Specifically from generic_array produced by: sha2::Sha256::new().chain(b"blabla_93794926").result(); (without using unsafe Rust)
Josh Abraham
  • 959
  • 1
  • 8
  • 18
-3
votes
3 answers

How does SHA generate unique codes for big files in git

Using Git I don't understand how using SHA you can generate just a 40 hexadecimal digit code that can then be mapped to any file which could be hundreds of lines long. The way I'm thinking of it, lets say the string '1' -> 00...01, the string '2' ->…
user2802557
  • 747
  • 1
  • 9
  • 19
-3
votes
1 answer

SHA Encryption doesn't work

Below is the code I have written for SHA encryption. But compiling this, gives an exception java.security.NoSuchAlgorithmException: SHA SecretKeyFactory not available Please some one help to solve this? Actually am not familiar with encryption…
Gapchoos
  • 1,422
  • 5
  • 20
  • 40
-3
votes
3 answers

How to reverse SHA1 Encrypted text

I have a requirement to reverse translate a SHA1 encrypted text to plain text. I need the Java Code to it. many forums say that it cant be done but i have found a link http://www.stringfunction.com/sha1-decrypter.html which does exactly the same. I…
Fr_nkenstien
  • 1,923
  • 7
  • 33
  • 66
1 2 3
88
89