简体   繁体   中英

Does anyone know where there is c# code or a dll which can generate sample credit card numbers

For an application we are working on I need to generate sample credit card numbers which pass the Luhn algorithm but which are also unique, so we cannot use the sample credit card numbers.

We need to be able to generate around 300 card numbers at a time, and ideally i would be able to do this when generating my input data.

Many Thanks

Create random numbers, then calculate the checksum number.

You can find more information at Wikipedia - Luhn , both details about the algorithm and links to different implementations.

From what I see you just need to ensure that when running through the algorithm you get a result of 0 (mod 10). So you can pick any number of random digits (or sequential if you like) and just add one last digit which will ensure that the number is valid.

我从Graham Kings网站上获取代码并将其移植到c#,同时通过电子邮件发送给Graham一份副本,你可以在这里找到链接文本

Do you need the credit card #'s to pass any other tests? ie should they look like valid VISA, MasterCard, or AMEX, etc.

If so, you may want a resource like Graham King's otherwise some of the other suggestions here are good.

The latest version of Graham King's generator (including c# code) can be found on GitHub .

If you need a list to test each card, you'll find one here. How to test credit card interactions?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM