Skip to main content

SHA-256 initial values

The simple workout to arrive at the initial values for sha-256

The first 32 bit of the fractional part of the sqroot (first 8 prime number 2-19)

Alright what does it say 

Sqrroot(prime)-

Let’s say the first prime is 2

Sqroot(2)  = 1.414213562373095

Convert to hexadecimal-

Since we are worried about the fractional part alone

Converting the fractional part would be easy

Fractional part-

0.414213562373095

Multiply the fractional part with 16 to arrive at hex

0.414213562373095*16= 6.62741699796952

0.62741699796952*16= 10.03867196751232

0.03867196751232*16=0.61875148019712

0.61875148019712*16=9.90002368315392

0.90002368315392*16=14.40037893046272

0.40037893046272*16=6.40606288740352

0.40606288740352*16=6.49700619845632

0.49700619845632*16=7.95209917530112


Resulting hexadecimal would be 6a09e667 which is 

h0 := 0x6a09e667

Iam going to stop at the 8th iteration , why is that ?

Since we are interested in 32 bit (8*4=32)

Alright to make it clear 

Convert hexadecimal- binary arriving at 32 bits

Please have a look at the hex - bin table

6a09e667- 0110 1010 0000 1001 1110 0110 0110 0111

Enjoy hashing.




Comments

Popular posts from this blog

Node and Auth0 - Integration

 so now we have completed all the steps for integration  since we have the node and auth0 as two separate things the integration happens in the app.js  we need to modify the app.js with some auth0 code  app.js / const http = require('http'); const express = require('express'); var router = require('express').Router(); const { auth } = require('express-openid-connect'); const app = express(); app.use('/', router); const hostname = '127.0.0.1'; const port = 3000; http.createServer(app)   .listen(port, () => {     console.log(`Listening on `);   }); const config = {   authRequired: false,   auth0Logout: true,   secret: 'a long, randomly-generated string stored in env',   baseURL: 'http://localhost:3000',   clientID: 'QxpAXsXkzy0Vm2VdT6dFFS0VOKdrah67',   issuerBaseURL: 'https://dev-bnga041p.us.auth0.com' }; console.log(config) // auth router attaches /login, /logout, and /callback routes to the baseURL app.u

Auth0

You might be wondering what is this auth0  it is used for authentication of you applications  could be any apps  1.SPA - Angular , React  2.web app 3.Node  here we will talk about the node use case and go with example  moving ahead for now  if your are not familiar with node dont worry its a funny exercise for now walk with me  we dont have to worry too much for authentication as the service is  provided from auth0   create your node app  install node  https://nodejs.org/en/download/package-manager/  choose your os and do the installation once installed check for the version ' node -v  ' i assume u have installed so that u wil get the version for now  since iam using LINUX this will look like root@strings-desktop:/home/strings/js# node -v v16.13.0 moving on to creating node app for now    create a file app.js and paste the contents  app.js/ const http = require('http'); const express = require('express'); const app = express(); const hostname = '127.0.0.1&#