mvallim / emv-qrcode

Java Based EMV QR Code Generator and Parser (MPM, CPM)
https://mvallim.github.io/emv-qrcode/
Apache License 2.0
98 stars 48 forks source link

CRC16 Validating forcing the UTF-8 charset #9

Closed felipecamargo closed 3 years ago

felipecamargo commented 3 years ago

@mvallim

MerchantPresentedModeValidator uses the bytes from UTF-8 charset if any EMV string is sent with a different charset than UTF-8 it becomes impossible to do its validation.

private static Function<MerchantPresentedMode, String> calcCrc16(Function<MerchantPresentedMode, String> fnc) {
    return (obj) -> {
        return String.format("%04X", CRC.crc16(((String)fnc.apply(obj)).getBytes(StandardCharsets.UTF_8)));
    };
}

I suggest remove you to remove and do a simple .getBytes() with no charset definition.

Regards,