Parse Credit Card input from Magnetic Stripe

前端 未结 6 1804
故里飘歌
故里飘歌 2020-12-23 17:36

Does anyone know how to parse a credit card string input from a Magnetic Card Swiper?

I tried a JavaScript parser but never got it to work. This is what the input l

6条回答
  •  生来不讨喜
    2020-12-23 18:00

    See the Magnetic Stripe Card entry @ Wikipedia:


    Track one, Format B:

    • Start sentinel — one character (generally '%')
    • Format code="B" — one character (alpha only)
    • Primary account number (PAN) — up to 19 characters. Usually, but not always, matches the credit card number printed on the front of the card.
    • Field Separator — one character (generally '^')
    • Name — two to 26 characters
    • Field Separator — one character (generally '^')
    • Expiration date — four characters in the form YYMM.
    • Service code — three characters
    • Discretionary data — may include Pin Verification Key Indicator (PVKI, 1 character), PIN Verification Value (PVV, 4 characters), Card Verification Value or Card Verification Code (CVV or CVK, 3 characters)
    • End sentinel — one character (generally '?')
    • Longitudinal redundancy check (LRC) — one character (Most reader devices do not return this value when the card is swiped to the presentation layer, and use it only to verify the input internally to the reader.)

    I hope the data is fake, otherwise Anyone could get the:

    • Name
    • Expiration Date
    • CVV

    And I'm not sure but I think the credit card number (or # of possibilities) can be computed using the LRC.

提交回复
热议问题