Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
227 views
in Technique[技术] by (71.8m points)

java - 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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...