linux - Implement an algorithm in bash -
i have following algorithm, , want implement in bash.
void wepkey64(char *passphrase, unsigned char k64[4][5]) { unsigned char pseed[4] = {0}; unsigned int randnumber, tmp; int i, j; for(i = 0; < strlen(passphrase); i++) { pseed[i%4] ^= (unsigned char) passphrase[i]; } randnumber = pseed[0] | (pseed[1] << 8) | (pseed[2] << 16) | (pseed[3] << 24); (i = 0; < 4; i++) { (j = 0; j < 5; j++) { randnumber = (randnumber * 0x343fd + 0x269ec3) & 0xffffffff; tmp = (randnumber >> 16) & 0xff; k64[i][j] = (unsigned char) tmp; } } } what's equivalent of function in bash?
are sure /bin/sh on system bourne shell? on many systems /bin/sh boune-again shell (bash).. can check with:
sh --version if have access gawk, has bitwise operators described here: http://www.gnu.org/software/gawk/manual/html_node/bitwise-functions.html
i think original awk may lack these operators. again, sh , bash, awk gawk on many systems.
Comments
Post a Comment