Translating javascript to java -


i have been working on turning large javascript program java. unsure happening in these few lines here , how turn java.

    int val = 0; //already turned java      int o = hash.length() % 4;  //already turned java  (var = o > 0 ? o - 4 : 0; < hash.length; += 4) {         val = ((val << 16) + parseint(hash.substring(i, i+4), 16)) % mod;     } 

it divisible function. hash string (specifically sha256 string hash). able me figure out weird forloop? thanks.

i aware parseint turning base 16, have translated part other places in code.

for = o o greater 0 . else o-4 set 0

till less hash.length

iterate 4 each time

in loop each time : val equal -

val left shift 16 bits plus remainder of integer value base 16 of (ith element of hash i+4 element ) , "mod"

you have not provided definition mod.

the substring() method extracts characters string, between 2 specified indices, , returns new sub string.

this method extracts characters in string between "start" , "end", not including "end" itself.

if "start" greater "end", method swap 2 arguments, meaning str.substring(1,4) == str.substring(4,1).

if either "start" or "stop" less 0, treated if 0.

parseint() function

it parses input integer plus second argument specifies radix, base of number system in case hex

bitwise left shift, << operator

val i'm guessing value in hexadecimal number system in decimal system minus 1

ternary operator , loop

the operator can take 3 arguments, short hand if{} else{} loop .


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -