[patch] Luhn algorithm implementation should be added to Django
|Reported by:||Ben Slavin||Owned by:||Ben Slavin|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The Luhn algorithm is used for validating credit cards and numerous national ID numbers. Django should have a built-in implementation to enable localflavors to add functionality.
Factored out of #3961 to separate additions. Slight implementation details have been changed.
Re: discussion there, the Luhn algorithm works from right to left, so strings are used for processing. Quick (non-scientific) benchmarking shows this string-based method to be faster than other Python implementations available online.
Note: filed under 'internationalization', but arguments could be made for other categorizations.