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


Groups > comp.lang.python > #32699

Re: How to generate account number?

Date 2012-11-03 10:34 -0500
From Tim Chase <python.list@tim.thechases.com>
Subject Re: How to generate account number?
References <mailman.3220.1351890866.27098.python-list@python.org> <1gsdm9-r2c.ln1@crazy-horse.bildanet.com> <mailman.3234.1351931985.27098.python-list@python.org> <roy-1E6B33.09225503112012@news.panix.com>
Newsgroups comp.lang.python
Message-ID <mailman.3242.1351956818.27098.python-list@python.org> (permalink)

Show all headers | View raw


On 11/03/12 08:22, Roy Smith wrote:
> Even better might be base-32 encoding the value.  Strings of
> digits have an information density of about 3.2 bits/char.
> Base-32 is just about as readable, but gives you 5 bits/char, so
> you end up with a few less characters (which you still want to
> chunk into 3 or 4 character groups).

For things that will be read off a screen/paper, I recommend
omitting several letters that are easy to mistake visually:  i/I/l/1
and O/0 in particular.  The VIN (vehicle identification number) on
all US cars avoids these characters[*], making it easier to read
them back without concern for "is that a zero or an oh; and is that
an ell, a one, a lowercase eye, or a capital eye?"  As an encoding
advantage,

>>> print len(''.join(c for c in (string.ascii_uppercase +
string.digits) if c not in "O0iIl1"))
32

the number 32 is pretty handy when dealing with binary :-)

-tkc


[*]
The VIN avoids "Q" too and does use the digits 0/1, but the idea
holds.  Make it easy to ready back.

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


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