Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39272

Verification of bank number using modulus 11

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <mortenengv@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.021
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'algorithm': 0.03; 'python': 0.09; '8bit%:2': 0.09; 'calculating': 0.09; 'subject:number': 0.09; 'subject:using': 0.09; 'advance': 0.10; 'def': 0.10; 'resulting': 0.13; '(result': 0.16; 'document:': 0.16; 'isbn': 0.16; 'multiplied': 0.16; 'structure.': 0.16; 'used."': 0.16; '\xa0def': 0.16; '\xa0here': 0.16; 'team,': 0.18; 'trying': 0.21; 'message-id:@mail.gmail.com': 0.27; 'url:cz': 0.29; 'url:download': 0.29; '"the': 0.29; '8bit%:5': 0.29; 'skip:& 10': 0.29; 'becomes': 0.30; 'could': 0.32; '"")': 0.33; 'to:addr :python-list': 0.33; 'code:': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'false': 0.35; 'but': 0.36; 'method': 0.36; 'should': 0.36; 'to:addr:python.org': 0.39; 'apply': 0.39; 'mentioned': 0.63; 'here': 0.65; 'validate': 0.65; 'account': 0.67; '8bit%:100': 0.70; 'banks': 0.71; '11.': 0.81; '10th': 0.84; '2.7.': 0.84; '8bit%:24': 0.84; 'subject:Verification': 0.84; 'url:export': 0.84; 'norway': 0.91; 'divided': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=U/KnUlSVcyMS2RdF+xplH+bIEwBGBwVhsOREnbPrblE=; b=lAffPbFarqn2B2HkeXHB7WNScnEP9kmPBMgP1bDIV8OtvwSqG5LMMcRxYDMu9Oz0Tc 8Yd88OEEMXHcLhPycWV2h0ajjDMT4WPYSSd+13YuZ6frYgAhOuWXLYgONIdDHYJDb/Rg 7e2KtxffhmzNV1xB4qgeC6qkxapVeKBn59aX8H9BBukgDJgtOJfiSXs2Q95Lm3iCC2mB EH++zDjOdKQkEFIMfeuzErreF22VgbXao0YUX+wcb2+wNePaX+5Y9AEF+mV0SxF1pwAl jGQp4m7O20Vaq3m2t/2fl1LyCyXuC50mBEah9+vHXvc6zmUTGQctgBCuSfaHAY4hJjRs FnOw==
MIME-Version 1.0
X-Received by 10.43.17.199 with SMTP id qd7mr8152206icb.52.1361307018845; Tue, 19 Feb 2013 12:50:18 -0800 (PST)
Date Tue, 19 Feb 2013 21:50:18 +0100
Subject Verification of bank number using modulus 11
From Morten Engvoldsen <mortenengv@gmail.com>
To python-list@python.org
Content-Type multipart/alternative; boundary=bcaec51968c949dc7404d619fdcb
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2060.1361307023.2939.python-list@python.org> (permalink)
Lines 125
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1361307023 news.xs4all.nl 6947 [2001:888:2000:d::a6]:53825
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:39272

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi Team,
I am trying to verify the account number using the following algorithm:

"The valid account number is 11 numeric digit without seperator. Eg.
86011117947 is a valid account number. All banks apply a modulus-based
method for the validation of the account structure. The 10-digit account
number is multiplied from left to right by the following weights: 5, 4, 3,
2, 7, 6, 5, 4, 3, 2. The resulting numbers are added up and divided by 11.
The remainder is subtracted from 11 and becomes the check digit. If the
remainder is 0, the check digit will be 0. If digits 5 and 6 of the account
number are zeros, the check digit is calculated on the 7, 8, 9 and 10th
digit of the account number. Account numbers for which the remainder is 1
(check digit 10) cannot be used."

 I am trying to validate the Norway account number using the algorithm
mentioned in the following document:
http://www.cnb.cz/miranda2/export/sites/www.cnb.cz/cs/platebni_styk/iban/download/TR201.pdf

Here is my code:
 def calc_checkdigit(isbn):
        isbn = isbn.replace(".", "")
        check_digit = int(isbn[-1])
        isbn = isbn[:-1]
        if len(isbn) != 10:
               return False
        result = sum((10 - i) * (int(x) if x != 'X' else 10) for i, x in
enumerate(isbn))
        return (result % 11) == check_digit

calc_checkdigit(""8601.11.17947"")

In my program : it is calculating 10 digit with weights 10-1, but according
to above algorithm the weights should be : 5, 4, 3, 2, 7, 6, 5, 4, 3, 2.

Could you please let me know how can i calculate the 10 digit with weights
5, 4, 3, 2, 7, 6, 5, 4, 3, 2. I am using python 2.7.

Thanks in advance team for help..







):

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Verification of bank number using modulus 11 Morten Engvoldsen <mortenengv@gmail.com> - 2013-02-19 21:50 +0100

csiph-web