TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: SHA-256 explained step-by-step visually

1241 点作者 manceraio超过 3 年前

37 条评论

oconnor663超过 3 年前
Oh this is great. When we taught SHA-256 last semester, we linked to this YouTube video: <a href="https:&#x2F;&#x2F;youtu.be&#x2F;f9EbD6iY9zI" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;f9EbD6iY9zI</a>. Next time we do it, we&#x27;ll probably link to both. Having several different ways to visualize the same thing is very helpful, and I like that this one moves quickly.<p>A couple of details missing from this visualization are how you pad a message to be a multiple of the block size, and how you chain blocks together to form a longer message. In the pseudocode at <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;SHA-2#Pseudocode" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;SHA-2#Pseudocode</a>, that&#x27;s the &quot;Pre-processing (Padding)&quot; part and the &quot;for each chunk&quot; loop just below it. I get why you&#x27;d want to leave those things out, since they&#x27;re not really the interesting part, and the screen is already pretty packed as it is.<p>If anyone&#x27;s feeling curious about implementing this yourself, take a look at these project notes: <a href="https:&#x2F;&#x2F;github.com&#x2F;oconnor663&#x2F;applied_crypto_2021_fall&#x2F;tree&#x2F;main&#x2F;sha256" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;oconnor663&#x2F;applied_crypto_2021_fall&#x2F;tree&#x2F;...</a>. At some point I&#x27;ll clean that up for public consumption, but for now just ignore the parts about grades and cheating :)
评论 #30247472 未加载
评论 #30253054 未加载
评论 #30256315 未加载
评论 #30257248 未加载
picture超过 3 年前
So, how do people come up with these things? I assume every aspect of the design is carefully considered to defend it against various attacks. For example, why &quot;right rotate 7 XOR right rotate 18 XOR right shift 3&quot; and not &quot;right rotate 2 XOR right rotate 3 XOR right shift 4&quot;?
评论 #30249079 未加载
评论 #30250275 未加载
评论 #30247463 未加载
评论 #30249188 未加载
评论 #30248439 未加载
评论 #30248882 未加载
评论 #30249064 未加载
taviso超过 3 年前
That&#x27;s really cool. I made a terrible one for SHA1 years ago, yours is 1000x better.<p><a href="https:&#x2F;&#x2F;lock.cmpxchg8b.com&#x2F;sha1&#x2F;visualize.html" rel="nofollow">https:&#x2F;&#x2F;lock.cmpxchg8b.com&#x2F;sha1&#x2F;visualize.html</a><p>I read a paper at the time where someone described a tool they made to find a near-collision, they explained they were just flipping bits and visually observing the affects. That sounded kinda fun, but they didn&#x27;t release it, so I tried to replicate it from their description!
评论 #30252920 未加载
mabbo超过 3 年前
Before watching this: &quot;Why can&#x27;t cryptographers just figure out some tricks to crack these hash algorithms?&quot;<p>After watching this: &quot;How can any cryptographer EVER figured out any trick to crack these hash algorithms?!&quot;
评论 #30245561 未加载
评论 #30245934 未加载
userbinator超过 3 年前
This reminds me that I&#x27;ve always wanted to make a huge interactive combinatorial circuit that computes SHA-256 and shows all its internal state, then put it on a site with the claim that anyone who can make its output match a certain clearly-constructed value (e.g. 0123456...ABCD...) will win a prize. No mentions of hash algorithms or other such phrasing to deter anyone. I wonder how many people would try such a &quot;logic puzzle&quot;, how much time they&#x27;d spend on it, and if we might even get the first successful preimage attack from that.
评论 #30248542 未加载
评论 #30245580 未加载
nayuki超过 3 年前
My way of explaining step by step visually is by implementing in Excel: AES <a href="https:&#x2F;&#x2F;www.nayuki.io&#x2F;page&#x2F;aes-cipher-internals-in-excel" rel="nofollow">https:&#x2F;&#x2F;www.nayuki.io&#x2F;page&#x2F;aes-cipher-internals-in-excel</a> ; DES <a href="https:&#x2F;&#x2F;www.nayuki.io&#x2F;page&#x2F;des-cipher-internals-in-excel" rel="nofollow">https:&#x2F;&#x2F;www.nayuki.io&#x2F;page&#x2F;des-cipher-internals-in-excel</a> .<p>Also relevant: <a href="https:&#x2F;&#x2F;www.righto.com&#x2F;2014&#x2F;09&#x2F;mining-bitcoin-with-pencil-and-paper.html" rel="nofollow">https:&#x2F;&#x2F;www.righto.com&#x2F;2014&#x2F;09&#x2F;mining-bitcoin-with-pencil-an...</a>
y42超过 3 年前
There also exists a written description showing the process in Python, step by step, which I consider more helpful, because you do not need to stop and play the video.<p><a href="https:&#x2F;&#x2F;nickyreinert.medium.com&#x2F;wie-funktioniert-der-sha256-algorithmus-im-detail-teil-1-2-7a0023cf562a" rel="nofollow">https:&#x2F;&#x2F;nickyreinert.medium.com&#x2F;wie-funktioniert-der-sha256-...</a>
评论 #30249110 未加载
p1mrx超过 3 年前
Can it be proven whether values of m exist such that SHA256(m) == 0?<p>If I were omnipotent and wanted people to believe in me, I would write a book that hashes to 0, so that anyone could verify its authenticity.
评论 #30254292 未加载
评论 #30250188 未加载
评论 #30248684 未加载
评论 #30247025 未加载
ypcx超过 3 年前
Similar project which visualizes SHA-256 into terminal: <a href="https:&#x2F;&#x2F;github.com&#x2F;in3rsha&#x2F;sha256-animation" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;in3rsha&#x2F;sha256-animation</a>
spdebbarma超过 3 年前
This comes to my attention at a really convenient time. As a teenager, I initially got interested in Computer Science due to cryptography. Over a decade later, I&#x27;ve gotten into the subject for the first time since then.<p>For the last few days, I&#x27;ve been writing my own encryption for fun even though it&#x27;s 100% not secure enough or powerful. My belief is that even though it&#x27;s not super useful, the experience of attempting to write one is teaching me a lot more than I would have by simply studying it.
评论 #30248674 未加载
brk超过 3 年前
How long before we see this website as the source for some &quot;hacker sequence&quot; in a movie where a person wearing a black hoodie states they are &quot;... working on cracking their SHA-256 encryption, should only take a sec.&quot;
评论 #30246535 未加载
评论 #30246898 未加载
DJPocari超过 3 年前
This is fantastic. I once implemented SHA-256 in Google Sheets to visualize it, but it had horrible performance compared to this. This is the best visualization I&#x27;ve seen yet.
westurner超过 3 年前
SHA2: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;SHA-2" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;SHA-2</a><p><a href="https:&#x2F;&#x2F;rosettacode.org&#x2F;wiki&#x2F;SHA-256" rel="nofollow">https:&#x2F;&#x2F;rosettacode.org&#x2F;wiki&#x2F;SHA-256</a><p>Hashcat&#x27;s GPU-optimized OpenCL implementation: <a href="https:&#x2F;&#x2F;github.com&#x2F;hashcat&#x2F;hashcat&#x2F;blob&#x2F;master&#x2F;OpenCL&#x2F;inc_hash_sha256.cl" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;hashcat&#x2F;hashcat&#x2F;blob&#x2F;master&#x2F;OpenCL&#x2F;inc_ha...</a><p>Bitcoin&#x27;s CPU-optimized sha256.cpp, sha256_avx2.cpp, sha256_sse4.cpp, sha256_sse41.cpp: <a href="https:&#x2F;&#x2F;github.com&#x2F;bitcoin&#x2F;bitcoin&#x2F;blob&#x2F;master&#x2F;src&#x2F;crypto&#x2F;sha256_sse41.cpp" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bitcoin&#x2F;bitcoin&#x2F;blob&#x2F;master&#x2F;src&#x2F;crypto&#x2F;sh...</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;topics&#x2F;sha256" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;topics&#x2F;sha256</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;topics&#x2F;sha-256" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;topics&#x2F;sha-256</a><p>Cryptographic_hash_function#Cryptographic_hash_algorithms: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Cryptographic_hash_function#Cryptographic_hash_algorithms" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Cryptographic_hash_function#Cr...</a><p>Merkle–Damgård construction: <a href="https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Merkle%E2%80%93Damg%C3%A5rd_construction" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Merkle%E2%80%93Damg%C3%A5rd_...</a><p>(... <a href="https:&#x2F;&#x2F;rosettacode.org&#x2F;wiki&#x2F;SHA-256_Merkle_tree" rel="nofollow">https:&#x2F;&#x2F;rosettacode.org&#x2F;wiki&#x2F;SHA-256_Merkle_tree</a> ... Merkleized IAVL+ tree that is balanced with rotations in order to optimize lookup,: <a href="https:&#x2F;&#x2F;github.com&#x2F;cosmos&#x2F;iavl" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cosmos&#x2F;iavl</a><p>Self-balancing binary search tree: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Self-balancing_binary_search_tree" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Self-balancing_binary_search_t...</a> )
daenz超过 3 年前
You should be very satisfied with how well you conveyed the algorithm. Well done. What was your approach to arriving at this result?
评论 #30247591 未加载
chris_l超过 3 年前
Someone should make a collection of the various visualization web projects that crop up here from time to time.
jonathanyc超过 3 年前
I love single-purpose websites like this that put a potentially complex implementation behind an elegantly simple interface. This website’s design and styling are pretty too :) Another useful one is <a href="https:&#x2F;&#x2F;www.h-schmidt.net&#x2F;FloatConverter&#x2F;IEEE754.html" rel="nofollow">https:&#x2F;&#x2F;www.h-schmidt.net&#x2F;FloatConverter&#x2F;IEEE754.html</a> . I’d say even <a href="https:&#x2F;&#x2F;godbolt.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;godbolt.org&#x2F;</a> counts!
bmitc超过 3 年前
Does anyone have any good references, preferably a book but a good detailed website is fine, on cryptography, hashing, public&#x2F;private keys, tokens, encryption, etc. as it relates to a software engineer? I don&#x27;t necessarily want to know all the nitty gritty details of how these things are implemented. Rather, I think I would prefer simply understanding them and how to use them, piece them together, etc. to build something out of them.<p>I just have very little knowledge in this area. I&#x27;m going through a how to build a blockchain book right now, and I find myself struggling a little bit where I&#x27;m just calling some library functions but not necessarily knowing how to compose things properly.
评论 #30250482 未加载
评论 #30254335 未加载
评论 #30250535 未加载
anonymousDan超过 3 年前
I have an odd request regarding e.g. SHA-3. Can anyone tell me if it is implemented in a way that is in a sense &#x27;one-pass&#x27; over its input, i.e. each byte of its input in memory is accessed only once, after which all of the algorithm state is held in registers and the original input is never accessed again? My scenario is one where I&#x27;m concerned about TOCTOU-like attacks on the memory where the input is stored, but I don&#x27;t want to pay the overhead of first copying the whole input to a &#x27;safe&#x27; memory location, e.g. imagine I have kernel code wanting to compute a hash over data stored in userspace.
评论 #30255768 未加载
a-dub超过 3 年前
this is funny. when i first learned the algorithm, i found some matlab code that computes it with bit vectors. i added support for displaying them as an image and used the movie feature to generate step by step movies to build intuition.<p>nice to see someone build something polished that visualizes it in the same way. once you look at the mechanics for each round of the compression function and see the bits get swirled around for yourself, it starts to make intuitive sense.<p>the other big intuitions are of course, the trapdoor nature of add mod 2^32 (which is implicit in unsigned integer overflow on many machines) and the fact that some operations (like xor) operate in galois field 2, while others (like addition) operate in galois field 32 and the repeated stacking of the operations in different fields gives the function it&#x27;s nonlinear trapdoor property.<p>i remember reading a pretty good paper on the arx (add, rotate, xor) family of ciphers back in the day (sort of in the vein of, is that all you need?)...
Darkphibre超过 3 年前
Man, this is amazing. I had to hand-unroll bit packing in a binary encoding scheme we used in a game. Rare enough that making a tool wasn&#x27;t worth it, but damn I love your visualizations! Doing something like that would have helped others understand how I was &quot;seeing the matrix.&quot;
recursive超过 3 年前
On the third step(?) of the second step, it says &quot;Copy 2nd chunk into 1st 16 words&quot;, but it&#x27;s accompanied by a visualization of copying the <i>1st</i> chunk into the 1st 16 words. Am I just totally misunderstanding something?
seumars超过 3 年前
Fantastic presentation! The utility functions from the source code are just as useful.
ansible超过 3 年前
Is there a library or application that can take an annotated algorithm, and then generate a website like this one? That would be great for beginning CS and the sorting algorithms and other basic data structures too.
abrookewood超过 3 年前
Looks fantastic, but the only thing missing is <i>why</i> each step is done.
fthtls超过 3 年前
great visualization. i&#x27;ve also checked the source code and utility functions. they are very well defined and useful too.<p>i&#x27;ve coded a sha256 decrypter recently which uses dictionary attack and brute force. I read lots of articles about sha256 while coding this tool. there were still some missing parts on my mind, but your project clarified all.<p>btw, the decrypter i coded -&gt; <a href="https:&#x2F;&#x2F;10015.io&#x2F;tools&#x2F;sha256-encrypt-decrypt" rel="nofollow">https:&#x2F;&#x2F;10015.io&#x2F;tools&#x2F;sha256-encrypt-decrypt</a>
based2超过 3 年前
<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Secure_Hash_Algorithms" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Secure_Hash_Algorithms</a>
anandsuresh超过 3 年前
Pretty cool. Have been looking for something like this for a while. Thanks for building it.<p>Just sent you a PR for some typos I found while running through an example.
M4tze超过 3 年前
Great visualization. Might become my new screensaver.
评论 #30245642 未加载
stevofolife超过 3 年前
Well made! Can you share how you made the website?
sylware超过 3 年前
Can we have a video of this on youtube&#x2F;dailymotion&#x2F;vimeo&#x2F;etc which we can download with yt-dlp?
评论 #30275497 未加载
reincarnate0x14超过 3 年前
That&#x27;s super cool. Visualized or illustrated algorithms have always looked so magical, to me at least.
nwatab超过 3 年前
Looks bautiful. I understand it is really complicated (even I know calculation of SHA256)
dicroce超过 3 年前
Please do this for b+trees. :)
hombre_fatal超过 3 年前
Beautiful color palette.
berta超过 3 年前
This is awesome!
iqanq超过 3 年前
Two of the buttons at the top have no &quot;title&quot; attribute and therefore no tooltip.
jerpint超过 3 年前
Very satisfying!