1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| const offset = parseInt(Number(`0x${hmac_hash[hmac_hash.length - 1]}`), 10);
const token_hex_4bytes = hmac_hash.substring(offset * 2, offset * 2 + 4 * 2); let toekn_hex = '';
toekn_hex += ( '00' + (Number(`0x${token_hex_4bytes.substring(0, 2)}`) & 0x7f).toString(16) ).substr(-2);
for (let index = 2; index < token_hex_4bytes.length; index += 2) { const element = token_hex_4bytes.substring(index, index + 2); toekn_hex += ('00' + (Number(`0x${element}`) & 0xff).toString(16)).substr(-2); }
const token = Number(`0x${toekn_hex}`).toString().substr(-6); console.log(`token : ${token}`);
|