Welcome! Log In Create A New Profile

Advanced

Use mod 10 (Luhn) algorithm to generate instead of validate

Posted by Georgio 
Hi,

I have a rather large program that grants credit to clients and assigns account numbers from a control file. The account numbers are assigned sequentially. Some client's have run into issues of charging to incorrect accounts.

I'd like to use the Luhn formula to assign account numbers and then use it to validate.
Has anyone done this or know how to do it. (Windev 12)

Thanks!
Georgio
Hi Georgio,
The modulus 10 / Luhn algorithm is used to validate indendification numbers, credit card numbers. etc.
In case that this is what you need I can translate my Java implementation into WD, just drop a note. (The algo. is a piece of cake)
Bjoern
Hi,
The algoritm below first throws away garbage (e.g. dots), thereafter performs the Luhn check.
HTH


PROCEDURE CheckCreditCardLuhn(sCreditCardNumber)
sTmp is string
sAllow is string = "0123456789"
f is int
iSum is int = 0
bAlt is boolean = False
i is int
iVal is int

FOR f = 1 TO Length(sCreditCardNumber)
	IF Position(sAllow,sCreditCardNumber[[f]]) > 0 THEN
		sTmp += sCreditCardNumber[[f]]
	END
END

FOR i = Length(sTmp) TO 1 STEP -1
	iVal = Val(sTmp[[i]])
	IF bAlt THEN
		iVal = iVal * 2
		IF(iVal > 9) THEN
			iVal -= 9
		END
	END
	iSum += iVal
	bAlt = NOT bAlt
END

RESULT modulo(iSum,10) = 0
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: