<p><a href="http://preshing.com/20131219/bitcoin-address-generator-in-obfuscated-python/" rel="nofollow">Bitcoin Address Generator in Obfuscated Python</a> is a fun piece  of <a href="http://www.python.org" rel="nofollow">Python</a> 2.7 code:</p>

<pre><code>_                   =r"""A(W/2,*M(3*G
               *G*V(2*J%P),G,J,G)+((M((J-T
            )*V((G-S)%P),S,T,G)if(S@(G,J))if(
         W%2@(S,T)))if(W@(S,T);H=2**256;import&amp;h
       ashlib&amp;as&amp;h,os,re,bi    nascii&amp;as&amp;k;J$:int(
     k.b2a_hex(W),16);C$:C    (W/    58)+[W%58]if(W@
    [];X=h.new("rip           em    d160");Y$:h.sha25
   6(W).digest();I$                 d=32:I(W/256,d-1)+
  chr(W%256)if(d&gt;0@"";                  U$:J(k.a2b_base
 64(W));f=J(os.urando       m(64))        %(H-U("AUVRIxl
Qt1/EQC2hcy/JvsA="))+      1;M$Q,R,G       :((W*W-Q-G)%P,
(W*(G+2*Q-W*W)-R)%P)       ;P=H-2**       32-977;V$Q=P,L=
1,O=0:V(Q%W,W,O-Q/W*                      L,L)if(W@O%P;S,
T=A(f,U("eb5mfvncu6                    xVoGKVzocLBwKb/Nst
zijZWfKBWxb4F5g="),      U("SDra         dyajxGVdpPv8DhEI
qP0XtEimhVQZnEfQj/       sQ1Lg="),        0,0);F$:"1"+F(W
 [1:])if(W[:1           ]=="\0"@""        .join(map(B,C(
  J(W))));K$:               F(W          +Y(Y(W))[:4]);
   X.update(Y("\4"+                     I(S)+I(T)));B$
    :re.sub("[0OIl    _]|            [^\\w]","","".jo
     in(map(chr,ra    nge    (123))))[W];print"Addre
       ss:",K("\0"+X.dig    est())+"\nPrivkey:",K(
         "\x80"+I(f))""";exec(reduce(lambda W,X:
            W.replace(*X),zip(" \n&amp;$@",["","",
               " ","=lambda W,",")else "])
</code></pre>

<p>I'd check out these two Python modules:</p>

<ol>
<li><a href="https://pypi.python.org/pypi/python-bitcoinaddress" rel="nofollow">Bitcoinaddress</a> </li>
<li><a href="https://github.com/vbuterin/pybitcointools" rel="nofollow">Pybitcointools</a> (a fantastic Bitcoin library: see the <a href="https://github.com/vbuterin/pybitcointools/blob/master/README.txt" rel="nofollow">README.txt for usage</a>)</li>
</ol>

<p>A private key is just/can be a very large number. However it's not possible to use a calculator to calculate an address easily, mainly because:</p>

<ul>
<li>modular arithmetic is involved</li>
<li>base 58 check is not a straightforward conversion</li>
<li>there's appended bytes and such</li>
</ul>

<p>I'd recommend either <a href="http://gobittest.appspot.com/Address" rel="nofollow">this web app</a> to get the next best thing.</p>

CC BY-SA 3.0
2015-04-06T01:59:31.647Z
You also need a very good source of entropy, which a calculator (nor a human) possess. Absolutely never should you be outsourcing key generation to a third party as they (and everybody else watching your connection) can easily steal your money any time in the future.
Claris
CC BY-SA 3.0
2015-04-06T02:04:39.673Z
@Bitcoin Very good point. The only feasible way of getting entropy without a library is by rolling dice.
Wizard Of Ozzie
CC BY-SA 3.0
2015-04-06T01:58:34.943Z
2015-04-06T02:03:21.160Z
2015-04-06T02:03:21.160Z
Wizard Of Ozzie
<p>Is it possible to generate private and public keys using only a calculator?   If not how many lines of code would it take to write a wallet generator, and how difficult would it be?   How would you do this? </p>

<wallet>
Create a wallet generator?
RootFAIL
# Create a wallet generator?

(Asked by: username_0 on 2015-04-05)

Is it possible to generate private and public keys using only a calculator? If not how many lines of code would it take to write a wallet generator, and how difficult would it be? How would you do this?

**Tags:** wallet


---

## 1 answers

### Answer by username_1 on 2015-04-06. Score: 1 | Accepted answer

[Bitcoin Address Generator in Obfuscated Python](http://preshing.com/20131219/bitcoin-address-generator-in-obfuscated-python/) is a fun piece of [Python](http://www.python.org) 2.7 code:

```
_                   =r"""A(W/2,*M(3*G
               *G*V(2*J%P),G,J,G)+((M((J-T
            )*V((G-S)%P),S,T,G)if(S@(G,J))if(
         W%2@(S,T)))if(W@(S,T);H=2**256;import&h
       ashlib&as&h,os,re,bi    nascii&as&k;J$:int(
     k.b2a_hex(W),16);C$:C    (W/    58)+[W%58]if(W@
    [];X=h.new("rip           em    d160");Y$:h.sha25
   6(W).digest();I$                 d=32:I(W/256,d-1)+
  chr(W%256)if(d>0@"";                  U$:J(k.a2b_base
 64(W));f=J(os.urando       m(64))        %(H-U("AUVRIxl
Qt1/EQC2hcy/JvsA="))+      1;M$Q,R,G       :((W*W-Q-G)%P,
(W*(G+2*Q-W*W)-R)%P)       ;P=H-2**       32-977;V$Q=P,L=
1,O=0:V(Q%W,W,O-Q/W*                      L,L)if(W@O%P;S,
T=A(f,U("eb5mfvncu6                    xVoGKVzocLBwKb/Nst
zijZWfKBWxb4F5g="),      U("SDra         dyajxGVdpPv8DhEI
qP0XtEimhVQZnEfQj/       sQ1Lg="),        0,0);F$:"1"+F(W
 [1:])if(W[:1           ]=="\0"@""        .join(map(B,C(
  J(W))));K$:               F(W          +Y(Y(W))[:4]);
   X.update(Y("\4"+                     I(S)+I(T)));B$
    :re.sub("[0OIl    _]|            [^\\w]","","".jo
     in(map(chr,ra    nge    (123))))[W];print"Addre
       ss:",K("\0"+X.dig    est())+"\nPrivkey:",K(
         "\x80"+I(f))""";exec(reduce(lambda W,X:
            W.replace(*X),zip(" \n&$@",["","",
               " ","=lambda W,",")else "])

```

I'd check out these two Python modules:

1. [Bitcoinaddress](https://pypi.python.org/pypi/python-bitcoinaddress)
2. [Pybitcointools](https://github.com/vbuterin/pybitcointools) (a fantastic Bitcoin library: see the [README.txt for usage](https://github.com/vbuterin/pybitcointools/blob/master/README.txt))

A private key is just/can be a very large number. However it's not possible to use a calculator to calculate an address easily, mainly because:

* modular arithmetic is involved
* base 58 check is not a straightforward conversion
* there's appended bytes and such

I'd recommend either [this web app](http://gobittest.appspot.com/Address) to get the next best thing.

> **Comments:**
> **username_2**: You also need a very good source of entropy, which a calculator (nor a human) possess. Absolutely never should you be outsourcing key generation to a third party as they (and everybody else watching your connection) can easily steal your money any time in the future.  
> **username_1**: @Bitcoin Very good point. The only feasible way of getting entropy without a library is by rolling dice.  

---

