LRC Calculation algorithm

  • Thread starter Thread starter Sankalp
  • Start date Start date
S

Sankalp

Does anyone know how to calculate Longitudinal Redundancy Check(LRC) in
VB.NET?
I am trying to send Visa-II formatted even parity message to a credit
card processor and am not sure how to calculate the LRC which needs to
be appended to the message.

Any pointers would be most helpful.
Thanks in advance.
Sankalp
 
Does anyone know how to calculate Longitudinal Redundancy Check(LRC) in

I believe that the lrc byte is just the xor of all the data bytes.
 
Here is the code that I am using:
GenerateMessageETX() - This function returns the credit card
data and the ETX chanracter in the string format.
Then I create an HTTPWebRequest to the credit card payment gateway.


Dim message As String = pageData

Dim j As Integer

Dim LRC As Byte = "0"

For j = 0 To message.Length - 1
Dim chr As Char = message.Substring(j, 1)
LRC = LRC Xor Convert.ToByte(chr)
Next

Is this the LRC value or do i need to do something else.

Please guide-have been stuck in this for some time now.

Sankalp
 
Sankalp said:
Dim message As String = pageData
Dim j As Integer
Dim LRC As Byte = "0"
For j = 0 To message.Length - 1
Dim chr As Char = message.Substring(j, 1)
LRC = LRC Xor Convert.ToByte(chr)
Next

I don't like this:
Dim LRC As Byte = "0"

It probably gives a compiler error. I would code like this:

Dim message As String = pageData
Dim lrc As Integer = 0
For j As Integer = 0 To message.Length - 1
lrc = lrc Xor AscW(message.Chars(j))
Next

At this point, my guess is that you should transmit this string:
message & Chr(lrc)
It is your pageData string with one lrc byte appended.
 
Thanks A, tried this but doesnt work. Now I am beginning to doubt the
servers as well. They have given us 2 servers to test with one being
the backup server. But, both the servers are returning different
responses to the same message. I guess i will have to verify this with
the company. Thanks for your help again :-)

Sankalp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top