SHA-256 | COMPLETE Step-By-Step Explanation (W/ Example)

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ธ.ค. 2024

ความคิดเห็น •

  • @valerio21m
    @valerio21m 2 ปีที่แล้ว +74

    Great video!
    Btw, in the beginning you said that whatever bit length your input has, the padded message length would be the next 512 multiple. That is actually not fully true. That would only be true if the length of the input is smaller or equal to n*512 - 65 (if equal then k = 0). so if e.g. the input length is 960, the padded message will not be 1024 bits long, bc we would then have negative solution for k. But we cannot have a negative solution for k, so that’s why we would need to go with 1536.

  • @goldendovah7613
    @goldendovah7613 ปีที่แล้ว +75

    Love this type of video that goes into the meat of the algorithms instead of speaking abstractly. Thank you for this and well done!

    • @redblockblue
      @redblockblue  ปีที่แล้ว +12

      Yep, that’s the style I’m going for with this channel, there are far too many channels using only analogies and never going deeper than that

  • @thekingayu
    @thekingayu ปีที่แล้ว +29

    Only Video of Real SHA 256 algorithm implementation. Thank you for this.❤

  • @hardikmaind9833
    @hardikmaind9833 2 ปีที่แล้ว +11

    this is the best explanation you will find on youtube.

  • @frostieseditss
    @frostieseditss 7 หลายเดือนก่อน +86

    I searched this video thinking maybe I can reverse engineer this algorithm but turns out I have to give up on it😂😂

    • @pranavsuthar16
      @pranavsuthar16 6 หลายเดือนก่อน +1

      Why? Where was proble you ran in to

    • @borntosucceed1667
      @borntosucceed1667 6 หลายเดือนก่อน +7

      @@pranavsuthar16 - Because, wtf is this guy talking about?

    • @pranavsuthar16
      @pranavsuthar16 6 หลายเดือนก่อน

      @@borntosucceed1667 I am sure this guy saw sha256 on stake(online casino) and want to win it

    • @mohansurendar7429
      @mohansurendar7429 6 หลายเดือนก่อน +7

      Deep down, i started watching why cant we crack, EOD i just hardly understood the algo

    • @ian562ADF52E
      @ian562ADF52E 6 หลายเดือนก่อน +5

      @@pranavsuthar16 There is not a way to determine many of the bits dropped. Like in the maj() function, if the output is 1, it could be 101, 111, etc.

  • @jamesgebler5738
    @jamesgebler5738 2 ปีที่แล้ว +27

    Thank you so much for this video, for going through the trouble of understanding how it works and breaking it down into something meaningful! Having the example is SUPER helpful. Exactly what I was looking for.

  • @nataliazkontekstu
    @nataliazkontekstu 2 ปีที่แล้ว +26

    Oh my dear god, thanks for going through this insanity :D You're making it so much better than having to go through the whole paper itself. Same goes for Chaum's video! And I do enjoy the music and the humor! :)

    • @miaumi_24
      @miaumi_24 3 หลายเดือนก่อน +1

      Yes, really great vid! Maybe we could remove the music. Sometimes its a bit hard to listen to with headphones.

  • @shibainugamer
    @shibainugamer ปีที่แล้ว +10

    Great video, you're really underrated for the amount of effort you put into this.

  • @garydunken7934
    @garydunken7934 8 วันที่ผ่านมา

    Very good walk through to demonstrate SHA256 under the hood. Awesome mate.

  • @owenclark8166
    @owenclark8166 ปีที่แล้ว +2

    Amazing video. I was able to fully code the algorithm with the help of this explanation. Thank you!

  • @thebestminecraftplayerfrom376
    @thebestminecraftplayerfrom376 ปีที่แล้ว +5

    This guy deserves more subscribers!!

  • @nivlempert2799
    @nivlempert2799 27 วันที่ผ่านมา

    The most in depth video I’ve seen. Well done!

  • @mohansurendar7429
    @mohansurendar7429 6 หลายเดือนก่อน +1

    Thanks for using those book snippets, after reading them and watching your presentation made it very clear, thank you

  • @mikemccartneyable
    @mikemccartneyable 2 หลายเดือนก่อน

    Brilliantly explained and illustrated ... it really is the SHA256 hash of RedBlockBlue
    Command:
    echo -n "RedBlockBlue" | sha256sum
    Output:
    f8f05f79fe0c0f876d26368bd12c08ef31617039ae3104c34f22db9c0afd3bd9

  • @kashif3173
    @kashif3173 10 หลายเดือนก่อน +1

    Great video for sure! Very nice, simple explanation.
    Good job!

  • @mayumi8274
    @mayumi8274 ปีที่แล้ว +1

    Best one untill NOW..... Hats off

  • @Kartikhoney
    @Kartikhoney 3 หลายเดือนก่อน

    Thanks for the video, best explanation available on youtube

  • @brandonjade2146
    @brandonjade2146 2 ปีที่แล้ว +7

    you teach in a better way i have seen anyone else, thank you so much when is the video on the ethereum white paper coming out?

  • @anamashraf8996
    @anamashraf8996 10 หลายเดือนก่อน +1

    Wow, Thank you so much. Truly no bs.

  • @isidroarias6027
    @isidroarias6027 ปีที่แล้ว +9

    Thanks very much for the video!! I had to pause several times but I now understand better the algorithm.
    I also like that you show screenshots of the standard, it is a gentle introduction.
    I have some suggestions:
    - Use namespaced fonts. This avoid the misalignment of 10:34
    - Do you make the animations using Manim? In this case would be great that you share the source code :)

  • @LeonCoyne
    @LeonCoyne 12 วันที่ผ่านมา

    My head has just fallen off.. great work.

  • @slowgoins
    @slowgoins 10 หลายเดือนก่อน

    Thanks for making this video. It was nice to see all the steps actually laid out and what a crazy series of mathematical knots the algorithm ties the input data up in. (Also, for future videos, it would be worth normalizing audio volume up, mastering up, or running some different compression).

  • @bitcoinblackboard
    @bitcoinblackboard ปีที่แล้ว +2

    Amazing video.
    Your pedagogy skills are off the charts.
    ... but the music man ..............

  • @PotatoMan1491
    @PotatoMan1491 2 ปีที่แล้ว +3

    First 2 min of the video is already better than me reading for 30 min on wiki

  • @artahir123
    @artahir123 11 หลายเดือนก่อน +6

    hey why you stopped making videos ?

  • @kenedi987
    @kenedi987 10 หลายเดือนก่อน

    Amazing video, exactly what I was looking for.

  • @akashelangovan6924
    @akashelangovan6924 ปีที่แล้ว +1

    the best explanation

  • @mahmoudkaffel3188
    @mahmoudkaffel3188 2 ปีที่แล้ว +6

    If you do the bitwise addition of Sigma0 shown at 07:24 then the result I found is 00000011100011111110100110110000. Would you please explain if there is sth wrong ?

    • @redblockblue
      @redblockblue  2 ปีที่แล้ว +2

      Yep, you're correct. I believe I used the correct sum going forward though so the error doesn't carry forward through the rest of the steps. Good spot.

    • @seancantwell12
      @seancantwell12 ปีที่แล้ว +1

      I was having the same issue, appreciate this comment!

    • @rileycarlson3714
      @rileycarlson3714 ปีที่แล้ว +1

      Encountered the same thing. Glad I'm not crazy

  • @romeooltean6614
    @romeooltean6614 2 หลายเดือนก่อน

    this man deserves the subscribe and the like

  • @julianpinelli7627
    @julianpinelli7627 9 หลายเดือนก่อน +1

    Great video!!!

  • @svetlanaulianova1210
    @svetlanaulianova1210 ปีที่แล้ว +2

    hmm I don't get it, why creating initial hash values at 3:28 introduces randomness? if we know, which prime numbers we are taking?

  • @patkoono
    @patkoono 2 ปีที่แล้ว +1

    Best explanation ever !!

  • @ahjsbkdjhavkcjhvac
    @ahjsbkdjhavkcjhvac ปีที่แล้ว +2

    very interesting, cant wait to implement it 😋

  • @polymethh
    @polymethh 2 ปีที่แล้ว +2

    insane explanations thanks man!

  • @pocketrockets488
    @pocketrockets488 ปีที่แล้ว +1

    Great video. Thank you for the content. Can you give the link to the paper you are referencing in the video?

  • @waylonjepsen7730
    @waylonjepsen7730 6 หลายเดือนก่อน +1

    Would you provide a resource to the pdf you keep referencing in the video?

  • @brownsugar2549
    @brownsugar2549 6 หลายเดือนก่อน +1

    Which editing software you used ?

  • @blahmore9010
    @blahmore9010 2 ปีที่แล้ว +2

    OMG
    this was the best

  • @chandanapolaki3179
    @chandanapolaki3179 2 ปีที่แล้ว +2

    nice explanation i love it

  • @brownsugar2549
    @brownsugar2549 6 หลายเดือนก่อน +1

    Bro which editing software you used to edit this video ?

  • @David-mk2hp
    @David-mk2hp 10 หลายเดือนก่อน +1

    What is the source of the document you show screenshots of?

  • @calebtanner4919
    @calebtanner4919 6 หลายเดือนก่อน +1

    Not to be "that guy" but in your initial values for RedBlockBlue, you have different values for the two capital Bs. Do you remember if you used the values as shown for your calculations or were the correct values used?

  • @spektara
    @spektara ปีที่แล้ว +2

    7:24 when making addition modulo 2 for sigma0:
    Is the result shown correct? ("00000001 10001111 11101001 00000101")
    In my calculation it should be ("00000011 10001111 11101001 10110000")

    • @tukemo5788
      @tukemo5788 11 หลายเดือนก่อน

      I agree, I also got 00000011100011111110100110110000

  • @Ashlim_Tamang
    @Ashlim_Tamang ปีที่แล้ว +1

    Can you tell me the name of the book from which you have been explaining in the video?

    • @tanmay4751
      @tanmay4751 11 หลายเดือนก่อน

      Did you find it? I'm also looking for it

  • @omarsalam7586
    @omarsalam7586 2 หลายเดือนก่อน +1

    Thank you
    could you mention the name of a book you follow

  • @Daniel_Mathews
    @Daniel_Mathews 2 ปีที่แล้ว +3

    Great explanation. The easiest to understand from what Ive seen on TH-cam so far. But I dont quite get how the looping works... Are all the iterations added to eachother at the end?

  • @adambui7935
    @adambui7935 ปีที่แล้ว

    This out of this world

  • @kasra4641
    @kasra4641 4 หลายเดือนก่อน

    thank you for existing

    • @redblockblue
      @redblockblue  4 หลายเดือนก่อน

      I appreciate that

  • @abrhamb2952
    @abrhamb2952 29 วันที่ผ่านมา

    Great video, Thank You

  • @laracroft4saknfettig697
    @laracroft4saknfettig697 ปีที่แล้ว +1

    Why wouldn't you say modulo to 32nd? How would modulo prevent it from being greater than 32 bits? That is the only reason for the modulo portion, correct?

  • @nigelkay6264
    @nigelkay6264 6 หลายเดือนก่อน +1

    brain usage 100%, alert death imminent😂😂

  • @ian562ADF52E
    @ian562ADF52E 6 หลายเดือนก่อน

    This was perfect, thank you!

  • @bhimraddyyarabandi6512
    @bhimraddyyarabandi6512 ปีที่แล้ว +1

    amazing video

  • @eliaskountouris4214
    @eliaskountouris4214 3 หลายเดือนก่อน

    Great video. At 7:18 the first 2 bytes of the sigma_0 result should be 03 not 01.

  • @laracroft4saknfettig697
    @laracroft4saknfettig697 ปีที่แล้ว +1

    8:50 - why do we only go through that for loop once? What does t=0 to 63 repreent what is the 't' in this case?

    • @tmahad5447
      @tmahad5447 ปีที่แล้ว

      when you're a not a programmer and tries to understand sha256

  • @setherine9071
    @setherine9071 2 หลายเดือนก่อน

    What's the name/link of the paper you used?

  • @x86_architecture10
    @x86_architecture10 2 ปีที่แล้ว +4

    What will happen if the text we are trying to hash is 504 bits long? You don't have 64 bits to represent the length of the text in binary to be able to add to the end of the binary for it to be 512 bits in length. Your hash will instead be 568 bits long.

    • @kyrylopisariev9791
      @kyrylopisariev9791 2 ปีที่แล้ว +7

      you will then need to extend it it 1024 I guess

    • @valerio21m
      @valerio21m 2 ปีที่แล้ว +3

      @@kyrylopisariev9791yes exactly

    • @diogocardoso265
      @diogocardoso265 ปีที่แล้ว +1

      Have you tried convert the text into shingles/ tokens? In that way, you avoid having text longer than 504 bits

    • @x86_architecture10
      @x86_architecture10 ปีที่แล้ว

      @@diogocardoso265 How do you do that?

  • @sagarkhangwal8088
    @sagarkhangwal8088 หลายเดือนก่อน

    Can someone tell me what all I need to have a knowledge of in order to fully understand this video ?

  • @whramijg
    @whramijg ปีที่แล้ว

    really nice video. Thank you for creating it

  • @henriqeduu
    @henriqeduu ปีที่แล้ว +1

    One thing I dont get is, since every oitpit is the same lenght, can there be 2 strings with the same output?

    • @mirsaidabdullaev1431
      @mirsaidabdullaev1431 ปีที่แล้ว +2

      Yes, as a hashing function is many-to-one relationship, and involves a finite number of outputs given an infinite domain - if you are interested in this more, you might want to read up on hashing functions, hash maps and most importantly, how a function deals with "collisions" - which are what you outlined, hashes that are the same but given different outputs. :)

    • @hamburgerfatso
      @hamburgerfatso ปีที่แล้ว

      yeah but there are so many gajillions of outputs, good luck finding two strings that give the same output

  • @JarppaGuru
    @JarppaGuru 10 หลายเดือนก่อน

    3:59 we still doing stuff allways same. we can reverse. we not even need calculate those if it allwats start 2 then 3 then 5. we allways have those "hashes"

  • @ОлегКравець-в8к
    @ОлегКравець-в8к 8 หลายเดือนก่อน

    Love it, thank you for video!

  • @editsblazing
    @editsblazing 20 วันที่ผ่านมา

    Legend ❤

  • @halimashemsedin8792
    @halimashemsedin8792 5 หลายเดือนก่อน +3

    This is more complicated than anything I came across 😢

  • @10bokaj
    @10bokaj หลายเดือนก่อน

    what paper are you using?

  • @itealaaalaaeddin4080
    @itealaaalaaeddin4080 2 ปีที่แล้ว +2

    Wonderful video my dear friend
    I urgently need the presentation file you used please

  • @iloveforklifts
    @iloveforklifts 2 ปีที่แล้ว

    Great Video!

  • @okmm2807
    @okmm2807 ปีที่แล้ว

    Thanks for the explainations. However the music is very distracting. If I want to listen to music while learning I would just have a video in the background.

  • @JarppaGuru
    @JarppaGuru 10 หลายเดือนก่อน

    8:05 are those calculated all original values or with answer we got so order is important LOL. i bet original numbers

  • @firstevidentenigma
    @firstevidentenigma 8 หลายเดือนก่อน

    Where is the document that is referenced in this video?

  • @EwarRob
    @EwarRob ปีที่แล้ว

    Question: at 7.23, how can you perform an xor on three inputs? There are only two bits available. I tried doing an xor function on the first two 32 byte numbers and then that output and the final input, and it still did not yield a correct answer??

    • @EwarRob
      @EwarRob ปีที่แล้ว

      I found you could do xor in python using the ^ symbol, but it produced the answer: 00000011100011111110100110110000, which is incorrect

    • @hkey4852
      @hkey4852 9 หลายเดือนก่อน

      @@EwarRobI think the content in the video is wrong, I get the same result as you in a different programming language!!!

  • @manle2052
    @manle2052 ปีที่แล้ว

    I have a question, Can you explain this to me? I have the character "耀". What are the steps to encode this character? It's not in the ascii encoding.

    • @JL11MUSIC
      @JL11MUSIC ปีที่แล้ว

      yes it is

    • @huvarda
      @huvarda ปีที่แล้ว

      if it wasnt then we couldnt see it

  • @DWM864
    @DWM864 2 ปีที่แล้ว +2

    man the audio is very low, but amazing video

  • @justchill3330
    @justchill3330 7 หลายเดือนก่อน

    what if some one uses the final hash and applies these all same operation in a reverse manner and get to the initial input?? (i know doing these operation in reverse will require hell lot of brains but this might be possible ?)

  • @wayneswildworld
    @wayneswildworld 10 หลายเดือนก่อน +2

    Knowing all the steps why can't people work backwords to get the original string?

    • @yaminipriyx
      @yaminipriyx 4 วันที่ผ่านมา

      Imagine SHA-256 as a machine that takes your input, grinds it up into microscopic pieces, and produces a unique "dust pattern" (the hash). While you can see the dust pattern, it’s impossible to reconstruct the original object because:
      Pieces of the original were destroyed during the grinding process (irreversible steps like mixing and modular arithmetic).
      The dust pattern doesn’t retain enough information to rebuild the original.

  • @yerrme6819
    @yerrme6819 2 หลายเดือนก่อน

    can you show us how to reverse it?

  • @sojasauce6722
    @sojasauce6722 ปีที่แล้ว

    10:50 how is he calculating this binary number. I still don’t quite understand

  • @kostabelov6376
    @kostabelov6376 9 วันที่ผ่านมา

    GOAT!!!!

  • @Saint-Nation-1
    @Saint-Nation-1 2 หลายเดือนก่อน +1

    I need a mathematics English teacher 😂

  • @capitanmarmota8562
    @capitanmarmota8562 2 ปีที่แล้ว

    Can you do the reverse example? getting a string to get a determined value from the function?

    • @redblockblue
      @redblockblue  2 ปีที่แล้ว

      Do you mean:
      Given a 256 bit output, find the input?
      No this is not possible, SHA256 (as with all cryptographic hash functions) is a 'one-way' function' meaning its impossible to invert (go google those terms and look at wiki if you're unfamiliar).
      To convince yourself this is true just look at the inner workings of the algorithm: it's composed of several 'mini' one-way functions such as bit-wise addition mod 2 (i.e. we pass the bits through an XOR gate) if the output is 1 then the input is either 01 or 10.. we can't even invert this function! Same goes for 'shift' function in the video, SHIFT3(11011100) = 00011011... those first 3 bits of the input could be anything and still give same output (b/c they're set to zero regardless) so we cannot invert this mini function either

    • @capitanmarmota8562
      @capitanmarmota8562 2 ปีที่แล้ว

      @@redblockblue thank you for the response. I had a challenge to find a string that returns something with the substring b00da when passed through the Sha256. I'm no criptographer, I had to brute force it

  • @JarppaGuru
    @JarppaGuru 10 หลายเดือนก่อน +1

    10:18 well using prime number those are allways same and function ch result same thing or is efg change every step. hope fully. make no sende otherwise LOL

  • @Sureshyadavkampe
    @Sureshyadavkampe หลายเดือนก่อน

    great 😇

  • @thachdev
    @thachdev ปีที่แล้ว

    bạn có tài liệu như ở trong video không, tôi hiện đang rất cần nó, cảm ơn

  • @_xilar
    @_xilar ปีที่แล้ว

    3:25 ok i found myself solving Rubic's cube and thinking about what I can implement on my website 😅

  • @instanslim
    @instanslim 3 หลายเดือนก่อน

    why 03.51 play
    6=0110 should 00110110
    a=1010 should 01100001 give me guidance on where I need to study?

    • @instanslim
      @instanslim 3 หลายเดือนก่อน

      sha 256 not for crypto, only whitepaper, crypto using BLAKE-256 from Daniel J. Bernstein.

  • @juliuschaesare4296
    @juliuschaesare4296 2 ปีที่แล้ว

    Can i use this for completing my school project

    • @redblockblue
      @redblockblue  2 ปีที่แล้ว

      You can use it for whatever you’d like 👍

    • @juliuschaesare4296
      @juliuschaesare4296 2 ปีที่แล้ว

      @@redblockblue thanks mate

  • @laracroft4saknfettig697
    @laracroft4saknfettig697 ปีที่แล้ว

    3:46, why are the online decimal to binary tools inaccurate? They give me 0.00000010110100011001

    • @waytech4630
      @waytech4630 ปีที่แล้ว

      What do you mean? Perhaps you calculated incorrectly.
      Correct algorithm is: (**Psuedo code)
      n = 2
      nSqrt = sqrt(n) = 1.4142135623730950488016887242097 ..
      nDecimals = 0.4142135623730950488016887242097..
      nDecimals32Bits = nDecimals * (2^32)
      hexValue = hex(nDecimals32Bits) = "0x6a09e667"
      binaryValue = 01101010000010011110011001100111

  • @andrewsingleplayer9513
    @andrewsingleplayer9513 ปีที่แล้ว

    Can u do one for ripemd160?

  • @ricotaline
    @ricotaline 2 ปีที่แล้ว

    Nice vidéo !

  • @vishalkap62
    @vishalkap62 2 ปีที่แล้ว

    SHA-256 algorithm designed by the US National Security Agency, is this correct??

    • @redblockblue
      @redblockblue  2 ปีที่แล้ว +1

      Yep, although that may sound dodgy it’s not an issue, the algorithm is completely described in detail and any ‘random’ numbers are generated in a natural way (fractional part of sqrt(2), etc.) and not just ‘hey, use *this* ‘random’ number. They have planted back doors into publicly used algorithms before though, watch the vid in description from computerphile

  • @Mhysthyckque
    @Mhysthyckque ปีที่แล้ว

    can u do the sha3 please?

  • @UzairHassan-ns2tb
    @UzairHassan-ns2tb ปีที่แล้ว

    If I am calculating W(16), on which bit I will have to apply the sigma0 and sigma1?
    Can anyone tell me?

    • @hyxl3r254
      @hyxl3r254 11 หลายเดือนก่อน

      When it says (t-15) or (t-7) t is the loop from 16-63. t is going through the loop, when solving w16, t is 16 so w16 -15 = w1, if its w38 for example then its w38-15 = w23 if u get it?

  • @IrfanKhan-ld4xk
    @IrfanKhan-ld4xk ปีที่แล้ว

    what would we do if our N was more than 1

    • @hyxl3r254
      @hyxl3r254 11 หลายเดือนก่อน

      If the n is number of blocks youre talking about then you have more than one block, follow the same steps just in the final when youre adding h0 = h0 +a
      Then you take h0 from the previous block and use the new a from the next block

    • @IrfanKhan-ld4xk
      @IrfanKhan-ld4xk 11 หลายเดือนก่อน

      thanks@@hyxl3r254

  • @mohankumarmahesh2380
    @mohankumarmahesh2380 ปีที่แล้ว +6

    only understood first 3 mins

  • @mayank9447
    @mayank9447 ปีที่แล้ว +15

    Only problem this video has is the low volume even with headphone

    • @rishav-parasar
      @rishav-parasar 10 หลายเดือนก่อน +1

      I guess you need to change your headphones

    • @WADAFOK
      @WADAFOK 9 หลายเดือนก่อน +2

      you are probably going deaf

    • @FallahPladasque
      @FallahPladasque 8 หลายเดือนก่อน +2

      The frequencies carrying this recording are pretty low, could have used more mid/high, you should in any case try a better pair of headphones!

    • @F30-Jet
      @F30-Jet 4 หลายเดือนก่อน

      Your ears are dying

  • @awskhanfar4743
    @awskhanfar4743 8 หลายเดือนก่อน

    i now understand why its impossible to decode the output of hash256

  • @doumkatekz
    @doumkatekz 6 หลายเดือนก่อน

    This video is good, but the music is so distracting.I had to stop after a bit

  • @andrew4165
    @andrew4165 20 วันที่ผ่านมา

    Is anyone else unable to reproduce that T2 value? Following the steps up to it I instead get
    11110100 01001111 01010010 00011001

  • @marsenault9683
    @marsenault9683 ปีที่แล้ว

    Encryption built by the government in the NSA but Bitcoin totally wasn't sure

  • @vishalkap62
    @vishalkap62 2 ปีที่แล้ว

    Impossible, even for quantum computers to crack SHA-256??