vb.net - How to Hash/checksum of string -


so have generator creates 26 hexadecimal character string has balance of ones , zeros when converted binary. 26.5.the first half of 27th characters binary value stored in buf. , last half used make first 106 bits nice , even. or should @ least. how use binary remnants in buf generate 27th char , make last 22 bits hash/checksum first 106? below generator.

dim rnd new random()     dim bin new stringbuilder()     dim buf integer = 0, buflen integer = 0, left integer = 53     integer = 106 0 step -1         buf <<= 1         if rnd.[next](i) < left             buf += 1             left -= 1         end if         if system.threading.interlocked.increment(buflen) = 4             bin.append("0123456789abcdef"(buf))             buflen = 0             buf = 0         end if     next     dim b string = bin.tostring()      textbox1.text = (b) 

how add on completing process?

you've got 106 0 step -1, means 107 iterations creating 26 hex digits three further bits in buf (though last one's guaranteed 0)... might make 108 , have add hex digit bin - doesn't matter it's 0, can apply >=22 bit hash/checksum algo data in bin , append hash/checksum value - know how slice least significant 4 bits off left, generate hex digit, , rotate - last time can , 3 , or or xor value on final hex digit generated - setting 2 trailing 0s added above. googling "vb checksum" turns lots of example code. if stuck, post code , specific problem.

separately, don't know vb maybe there's weird reason, can't imagine why you're using appears threadsafe increment local variable i'd assume in on executing thread's stack , inaccessible other threads?


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -