Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can SHA-1 algorithm be computed on a stream? With low memory footprint?

I am looking for a way to compute SHA-1 checksums of very large files without having to fully load them into memory at once.

I don't know the details of the SHA-1 implementation and therefore would like to know if it is even possible to do that.

If you know the SAX XML parser, then what I look for would be something similar: Computing the SHA-1 checksum by only always loading a small part into memory at a time.

All the examples I found, at least in Java, always depend on fully loading the file/byte array/string into memory.

If you even know implementations (any language), then please let me know!

like image 427
raoulsson Avatar asked Mar 22 '10 21:03

raoulsson


People also ask

Why is SHA-1 no longer secure?

SHA-1 is prone to length extension attacks. Since 2005, SHA-1 has not been considered secure against well-funded opponents; as of 2010 many organizations have recommended its replacement. NIST formally deprecated use of SHA-1 in 2011 and disallowed its use for digital signatures in 2013.

Why is SHA 256 better than SHA-1?

The basic difference between SHA1 vs. SHA256 or SHA1 vs SHA2 is the length of the key used to encrypt the data transferred online. SHA1 uses 160 bit long key to encrypt data while SHA256 uses 256 bit long key to encrypt data. SHA2 is a family of algorithms developed by the US government to secure the data online.

Is SHA1 faster than SHA2?

Edit: SHA-1 algorithm is faster (up to 10 times faster than SHA-2 with 256 bits, and 20 times faster than SHA-2 with 512 bits - at least in the .

Is Sha 256 better than SHA-1?

In a nutshell, SHA-256 is more reliable and secure than SHA-1. SHA-256 belongs to the family of SHA-2 cryptographic hash functions designed by the NSA and is commonly used in Blockchain. SHA-1 was one of the earliest cryptographic hash functions often used by SSL certificate authorities to sign certificates.


1 Answers

The Java docs say to use a MessageDigest class to compute SHA-1 on any arbitrary size data.

like image 188
Robert Harvey Avatar answered Sep 22 '22 03:09

Robert Harvey