raihanafroz / zkteco

ZKTeco Laravel Library
151 stars 57 forks source link

Fix reverseHex method for inputs with an odd number of digits #28

Open HalibutGitWiz opened 1 year ago

HalibutGitWiz commented 1 year ago

Util::reverseHex does not behave correctly when the input has an odd number of digits

echo Rats\Zkteco\Lib\Helper\Util::reverseHex('13E7'); // Outputs "E713", OK
echo Rats\Zkteco\Lib\Helper\Util::reverseHex('3E7'); // Outputs "E7", KO, should output E703

This can happen in real world usage when creating / updating the card ID of an user. The result is an incorrect card ID in the device.

This fix corrects this behavior by adding a leading zero so the input always has an even number of digits.