Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32688
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <andriy.kornatskyy@live.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'case.': 0.05; 'important,': 0.07; 'subject:How': 0.09; '"""return': 0.09; '(without': 0.09; 'any.': 0.09; 'cipher': 0.09; 'etc).': 0.09; 'global,': 0.09; 'subject:number': 0.09; 'url:activestate': 0.09; 'def': 0.10; 'sat,': 0.15; 'value.': 0.15; '(must': 0.16; 'call)': 0.16; 'examples:': 0.16; 'guessing': 0.16; 'number?': 0.16; 'sequential': 0.16; 'sorts': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; 'wrote:': 0.17; 'code,': 0.18; 'input': 0.18; 'discussion': 0.20; '+0000': 0.20; 'suggested': 0.20; 'to:name:python-list@python.org': 0.20; 'skip:- 40': 0.21; 'stick': 0.22; 'split': 0.23; 'to:2**1': 0.23; 'random': 0.24; 'thus': 0.24; 'header:In-Reply-To:1': 0.25; 'done.': 0.27; 'question': 0.27; 'thoughts': 0.27; "doesn't": 0.28; 'yes.': 0.29; 'date:': 0.29; 'url:code': 0.29; 'that.': 0.30; 'fri,': 0.30; 'url:2012': 0.30; 'function': 0.30; 'from:addr:live.com': 0.33; 'to:addr:python-list': 0.33; 'requirements': 0.33; 'consistent': 0.35; 'nov': 0.35; 'community': 0.35; 'subject:?': 0.35; 'there': 0.35; 'next': 0.35; 'add': 0.36; 'subject:': 0.36; 'ability': 0.36; 'but': 0.36; 'alone': 0.36; 'email addr:python.org': 0.36; 'two': 0.37; 'subject:: ': 0.38; 'from:': 0.38; 'some': 0.38; 'gives': 0.39; 'instead': 0.39; 'to:addr:python.org': 0.39; 'help': 0.40; 'your': 0.60; 'below,': 0.60; 'easy': 0.60; 'you.': 0.61; 'share': 0.61; 'here:': 0.62; 'email name:python-list': 0.62; 'personal': 0.62; 'more': 0.63; 'url:blogspot': 0.64; 'here': 0.65; 'account': 0.67; 'user,': 0.69; 'business': 0.70; 'consequences': 0.71; 'url:11': 0.71; 'presented': 0.72; 'subject:account': 0.74; 'challenge.': 0.84; 'dozen': 0.91; 'interested?': 0.91; 'charset:windows-1251': 0.97 |
| X-Originating-IP | [213.130.16.2] |
| From | Andriy Kornatskyy <andriy.kornatskyy@live.com> |
| To | <steve+comp.lang.python@pearwood.info>, "python-list@python.org" <python-list@python.org> |
| Subject | RE: How to generate account number? |
| Date | Sat, 3 Nov 2012 11:42:38 +0300 |
| Importance | Normal |
| In-Reply-To | <50944ba2$0$29967$c3e8da3$5496439d@news.astraweb.com> |
| References | <50944ba2$0$29967$c3e8da3$5496439d@news.astraweb.com> |
| Content-Type | text/plain; charset="windows-1251" |
| Content-Transfer-Encoding | quoted-printable |
| MIME-Version | 1.0 |
| X-OriginalArrivalTime | 03 Nov 2012 08:42:39.0177 (UTC) FILETIME=[2E536B90:01CDB99F] |
| 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.3235.1351932226.27098.python-list@python.org> (permalink) |
| Lines | 77 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1351932226 news.xs4all.nl 6891 [2001:888:2000:d::a6]:38987 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:32688 |
Show key headers only | View raw
Steven, see below, please. ---------------------------------------- > From: steve+comp.lang.python@pearwood.info > Subject: Re: How to generate account number? > Date: Fri, 2 Nov 2012 22:39:31 +0000 > To: python-list@python.org > > On Sat, 03 Nov 2012 00:13:19 +0300, Andriy Kornatskyy wrote: > >> Requirements for `account number` generator: >> >> 1. Issue pseudo random consistent number (must be unique for dozen >> millions of records) > > How much randomness do you need? From the perspective of any one user, a > simple incrementing counter returns arbitrary values, which may be "close > enough" to random. > > last_num = 103872 # Pick an arbitrary starting value. > def get_account_number(): > """Return the next account number.""" > global last_num > last_num += 1 > return last_num > > Stick that value in a database instead of a global, and you're done. > > What are the consequences of people guessing account numbers? If the > consequences are serious, then you need to make account numbers > cryptographically strong. If the account number alone is not important, > then you don't. Yes. There are consequences to not use sequential numbers, yet humans deal with it (enter as input somewhere, etc). The approach suggested here: http://mindref.blogspot.com/2012/11/generate-account-number.html is using Feistel cipher to generate pseudo random thus makes guessing account numbers hard (impossible?). >> 2. Easy check validity (without a need to make a database call) > > Add a check digit to the number you generate. There are all sorts of ways > to do that. Here are two examples: > > http://code.activestate.com/recipes/577692 > http://code.activestate.com/recipes/577691 These tell me how to verify some code, but doesn't how to generate it. The approach suggested here: http://mindref.blogspot.com/2012/11/generate-account-number.html gives you ability to customize `sample_f` function to make it unique to your business case. >> Interested? Read more here: > > If you ask a question here, please keep the discussion here, don't split > it to your personal blog. The question was rhetorical with my answer in the blog and discussion here to reach something. > Tell us your requirements in more detail, and we will try to help you. I have presented solution to `account number` challenge. So it was share with community and seek for thoughts if any.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 00:13 +0300
Re: How to generate account number? GangGreene <GangGreene@example.com> - 2012-11-02 18:02 -0400
RE: How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 11:38 +0300
Re: How to generate account number? Roy Smith <roy@panix.com> - 2012-11-03 09:22 -0400
Re: How to generate account number? Tim Chase <python.list@tim.thechases.com> - 2012-11-03 10:34 -0500
RE: How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 19:18 +0300
RE: How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 19:23 +0300
Re: How to generate account number? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-02 22:39 +0000
RE: How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 11:42 +0300
csiph-web