mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-23 00:06:17 -04:00
Luhn checksum tests
This commit is contained in:
parent
0e40daecb6
commit
54cb2d268b
2 changed files with 29 additions and 1 deletions
|
@ -64,9 +64,15 @@ class LuhnChecksum extends Operation {
|
|||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
|
||||
if (!(input)) return "0";
|
||||
|
||||
const checkSum = this.checksum(input).toString();
|
||||
|
||||
let checkDigit = this.checksum(input+"0");
|
||||
|
||||
checkDigit = (checkDigit === 0 ? 0 : (10-checkDigit)).toString();
|
||||
|
||||
return "Checksum: " + checkSum + "\n\nCheckdigit: " + checkDigit + "\n\nLuhn Validated String: "+ input + checkDigit;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue