Implementing sha256 in javascript

I'm currently trying to implement sha256 from scratch.

I am implementing the ch () function, the definition of which    ch(x,y,z) = (x&y) ^ (~x&z)

( &: indicate and close,: ^indicate xor gate,: ~negation)

I implemented like this:

function ch(x,y,z){
 (x&y) ^ (~x&z)
}

but after I implemented it, when I saw some other implementation, such as ashttp: //point-at-infinity.org/jssha256/, the implementation is as follows (below)

function SHA256_Ch(x, y, z) {
  return z ^ (x & (y ^ z));
}

What is this conversion?

Is it possible to get the same result from wikipedia?

Could you tell me the way?

----------------------------------------------- --- -------

Thank you for message!

ch () means: x selects y or z. When x is 0, z is selected, and when x is 1, y is selected

This is a critical offer for me. I wanted to know how desiner would find the second form of the ch function.

, , , .

sha256 ch, , . x , y 0, z , x z xor gate, x y . x , y y, z , z, xor gate;

, SHA256.

!!

+4
1

x, y, z 2 , , .

( ):

x  y  z  (x&y)^(~x&z)  z^(x&(y^z))
0  0  0  0             0
0  0  1  1             1
0  1  0  0             0  
0  1  1  1             1  
1  0  0  0             0  
1  0  1  0             0  
1  1  0  1             1  
1  1  1  1             1

ch() : x y z. x 0, z, x 1, y

1 ; , .

+3

All Articles