# [RESOLVED] Help!! Euro notes checksum Validation Problem!

• 04-16-2011, 08:42 AM
TheML
[RESOLVED] Help!! Euro notes checksum Validation Problem!
Hello,
I 'm working on Euro banknote validation, where I'm using authentication of the serial number of Euro banknotes by the calculation of the "checksum". Basically what this algorithm does is to replace the first letter of the serial number by a number (each letter represents where the banknote is originally from), then it calculates the sum of all digits. If the remaining of the division of that sum by 9 is 0 then your note is valid.

Some test data
EURO Serial Number
V44671133335
T27620110932
A00000000007

The last serial number "A00000000007" works properly. but the first two for some reason don't work properly.

Those are my javascript codes:
Code:

```<html> <body> <script type="text/javascript">                 var EBNSArray = new Array ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90"); function validation() {     var i;         var EBNS = document.forms["ebnsform"]["EBNS"].value;         if (EBNS.length != 11 && EBNS.length != 12)         {             alert ("Incorrect EBNS, please enter the correct EBNS");             return false;         }         if (EBNS.length == 11)         {                 var letter_real = EBNS.charAt(0);         }                        if (EBNS.length == 12)         {                 var letter_real = EBNS.charAt(1);         }                    var letter_enter = EBNS.substring(1,11);             var checkLetter = letter_enter % 9             if (letter_real == EBNSArray[checkLetter])     {          alert ("Correct EBNS");         return true;                      }     else     {         alert ("Incorrect EBNS, please enter the correct EBNS");                                return false;     }          } </script> <form id="ebnsform"> <P>Euro Banknote Number: <input type="text" id="EBNS" /><br /></form></center> <input type="button" onclick="validation()" value="Validation"/></p> </body> </html>```
• 04-16-2011, 10:23 AM
JMRKER
What alphabet are you using for the banknote letter verification? There seem to be more than 26 elements in the EBNSArray.

The following won't work...
Code:

```    var letter_enter = EBNS.substring(1,11);     var checkLetter = letter_enter % 9```
...because the letter_enter is a string and the modulo character "%" works on numbers.

Also, where does our checksum total calculation occur?

I'm suprised you even got one calculation to work correctly!
• 04-16-2011, 10:36 AM
Fang
Code:

```function validation() {     var i;         var EBNS = document.forms["ebnsform"]["EBNS"].value.toUpperCase();         if (EBNS.length != 11 && EBNS.length != 12)         {             alert ("Incorrect EBNS, please enter the correct EBNS");             return false;         }         var numericEBNS = EBNS.replace(EBNS.charAt(0), EBNS.charCodeAt(0));                 var mod = numericEBNS &#37; 9             if (!mod)     {          alert ("Correct EBNS");         return true;                      }     else     {         alert ("Incorrect EBNS, please enter the correct EBNS");                                return false;     }          }```
Where did you see the number of digits can be 11? AFAIK it is always 12
• 04-16-2011, 11:03 AM
TheML
Hi JMRKER
I'm using 26 alphabetic letter that are represented as numbers in the position of the ASCII table.
Code:

`"65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90"`
Also you have mentioned about "where does our checksum total calculation occur?"

Code:

```  var letter_enter = EBNS.substring(1,11);             var checkLetter = letter_enter % 9```
but I don't know how to sort it out... please, could you be so kind to help me?
• 04-16-2011, 11:50 AM
TheML
Thanks
Hi Fang,
I really appreciate your help. Thank you so much, now it is working properly!
• 04-16-2011, 12:31 PM
Fang
Where did you see the number of digits can be 11? AFAIK it is always 12
• 04-16-2011, 12:47 PM
JMRKER
Quote:

Originally Posted by Fang
Where did you see the number of digits can be 11? AFAIK it is always 12

OP appears to be counting the 1st letter as a number. Why ???

Also, his ESNBArray has 36 elements rather than the 26 supposedly in the english alphabet. Why ???

But if he's happy, let it be! ;)
• 04-17-2011, 08:13 PM
David Harrison
Quote:

Originally Posted by JMRKER
Also, his ESNBArray has 36 elements rather than the 26 supposedly in the english alphabet. Why ???

Numbers.
• 10-31-2013, 08:32 PM
Romek
The algorithm should be expanded
The algorithm should be expanded to take into account that the second character from the left can be digit or letter.
Valid Euro note number is VA0436214792

## X vBulletin 4.2.2 Debug Information

• Page Generation 0.13146 seconds
• Memory Usage 2,378KB
• Queries Executed 11 (?)
Template Usage (21):
• (5)bbcode_code_printable
• (2)bbcode_quote_printable
• (1)footer
• (1)gobutton
• (1)navbar_moderation
• (1)navbar_noticebit
• (2)option
• (1)spacer_close
• (1)spacer_open

Phrase Groups Available (3):
• global
• postbit
Included Files (19):
• ./global.php
• ./includes/class_bootstrap.php
• ./includes/init.php
• ./includes/class_core.php
• ./includes/config.php
• ./includes/functions.php
• ./includes/class_friendly_url.php
• ./includes/class_hook.php
• ./includes/class_bootstrap_framework.php
• ./vb/vb.php
• ./vb/phrase.php
• ./includes/functions_calendar.php
• ./includes/class_bbcode_alt.php
• ./includes/class_bbcode.php
• ./includes/functions_bigthree.php
• ./includes/functions_notice.php

Hooks Called (41):
• init_startup
• init_startup_session_setup_start
• database_pre_fetch_array
• database_post_fetch_array
• init_startup_session_setup_complete
• global_bootstrap_init_start
• global_bootstrap_init_complete
• cache_permissions
• fetch_foruminfo
• global_state_check
• global_bootstrap_complete
• global_start
• style_fetch
• global_setup_complete
• bbcode_fetch_tags
• bbcode_create
• bbcode_parse_start
• cache_templates
• cache_templates_process
• template_register_var
• template_render_output
• fetch_template_start
• fetch_template_complete
• parse_templates