解析来自磁条的信用卡输入
有谁知道如何解析从磁卡刷卡器输入的信用卡字符串?
我尝试过 JavaScript 解析器,但从未让它工作。这就是输入的样子。
%BNNNNNNNNNNNNNNNN^DOE/JOHN
^1210201901000101000100061000000?;NNNNNNNNNNNNNNNN=12102019010106111001?
N 是信用卡号码。
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 looks like.
%BNNNNNNNNNNNNNNNN^DOE/JOHN
^1210201901000101000100061000000?;NNNNNNNNNNNNNNNN=12102019010106111001?
The N's are the credit card number.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
请参阅磁条卡条目 @ Wikipedia:
我希望数据是假的,否则任何人都可以得到:我不确定,但我认为信用卡号(或可能性的数量)可以使用 LRC 计算。See the Magnetic Stripe Card entry @ Wikipedia:
I hope the data is fake, otherwiseAnyone could get the:And I'm not sure but I think the credit card number (or # of possibilities) can be computed using the LRC.我做得更好:我制作了一个视频,展示了如何使用 ASP.Net/c# 准确执行此操作:
http: //www.markhagan.me/Samples/CreditCardSwipeMagneticStripProcessing
这是您可能关心的代码部分:
完整的代码位于我上面链接的网站上。
I did you one better: I made a video showing how to do exactly this with ASP.Net/c#:
http://www.markhagan.me/Samples/CreditCardSwipeMagneticStripProcessing
Here is the section of code that you probably care about:
The complete code is on that website I linked above.
据我所知:
这是一个双轨磁条数据 - 第一磁道以
%
开头,以?
结尾,第二磁道以;< 开头/code> 并以
?
结尾。这些是开始/结束标记。第一个轨道是字母数字,第二个轨道是数字,第三个轨道也是数字(如果我没记错的话)。
开始/结束标记之间的数据可以根据磁条的记录密度而变化。密度越高,一个磁道上可以记录的内容就越多。
使用正则表达式获取数据可能不是挑选所需信息的可靠方法。
并非所有信用卡都有两个磁道,有些信用卡使用三个磁道。
From what I can remember:
That is a two-track magnetic strip data - first track starts with
%
and ends with?
, the second track starts with;
and ends with?
. These are Start/End markers.The first track is alphanumeric, the second track is numeric, and there is a third track which is numeric also (if my memory serves correct).
The data between the start/end markers can be variable depending on the recording density of the magnetic strip. The higher the density, the more it can be recorded on one track.
Using a regex to get at the data may not be a reliable method to pick out the information required.
And not all credit cards have exactly two tracks, some uses three tracks.
通常,对于无卡交易(即 MOTO 交易),您将需要 cc#、到期日以及可能的 CVV(又名 CVC2 等)。您可以通过刷卡获取前 2 个,就像在轨迹数据中一样。 CVV 印在卡上。
卡上的名字并不重要。除非您的收单机构和持卡人使用地址验证,但您可以发现 ^^ 之间可能有空白填充,您可以将其删除。
您想要的部分是 track2 NNNNNNNNNNNNNNNN=1210,其中 NNNNN= 卡号 PAN,1210 = 到期日期。
即使 track1 为空(有时是空的,因为它在处理中未使用),您仍然会得到 ;?,因此您可以使用第二个 ; 的索引。作为字符串的开头,= 作为 cc# 字符串的结尾。以 = 后面的 4 个字符作为过期时间。
我建议让持卡人在交易记录中签名,否则他们可能会对卡提出异议并进行退款。
仅使用 track2 进行处理并具有标准化格式。
借记卡通常无法处理(除非它们有 Visa 借记卡或其他卡)。
PS,您不应该以纯文本形式存储抄送数据,因此请尝试将所有内容保存在内存中或进行强加密。
Generally for a card-not present transaction (i.e. MOTO transactions) you will need cc#, expiry and possibly the CVV (aka CVC2 etc). You can obtain the first 2 from a card-swipe as this in the track data. CVV is printed on the card.
Name on card doesn't matter so much. Unless your acquirer and the cardholder are using address verification, but you can find that between ^^, it may have white space padding which you can remove.
The part you want is track2 NNNNNNNNNNNNNNNN=1210 where NNNNN=card number PAN, and 1210 = Expiry date.
Even if track1 is empty (which sometimes it is as it's not used in processing), you will still get the ;?, so you could use the index of the second ; as start of the string and = as the end of the cc# string. With the 4 characters after the = as the expiry.
I would advise getting the card holder to sign something in record of the transaction otherwise they could dispute the card and do a charge-back.
Only track2 is used for processing and has a standardized format.
Debit cards can't generally be processed (unless they have a visa-debit card or something).
P.S. you shouldn't store cc data in plain text, so try and keep everything in mem or strong encryption.
试试这个:
https://github.com/pdamer/CardReader/blob/master/CardReader.js
或者这个:
http://blog.cnizz. com/2008/10/16/javascript-snippet-for-handling-credit-card-readers/
我认为你需要什么
Try this :
https://github.com/pdamer/CardReader/blob/master/CardReader.js
Or this:
http://blog.cnizz.com/2008/10/16/javascript-snippet-for-handling-credit-card-readers/
I think that what u need
这是我的代码:
第一个获取数据的侦听器......该数据需要验证,我正在寻求帮助。良好的滑动效果很好,但不良的滑动会导致解析器出错。
这是解析器......注意,我将其全部放在一个函数中,这样我就可以销毁所有变量,这样它们就不会在浏览器中徘徊。
here is my code:
1st the listener to get the data.... this data needs validation which i am looking for help on. A good swipe works fine, but a bad swipe will cause an error in the parser.
And here is the parser.... note I put it all in one function so I can destroy all the variables so they are not lingering in a browser.