OK, so I wanted to have a small script that I can use to generate new (offline) bitcoin addresses and be sure that the information was not stored anywhere or sent to anyone, but I couldn't find anything that does that that's also simple enough that I can read the source code and verify it myself.
anyway I ended up writing this python 2.5 script (and then decided to upload it here, in case it's useful to anyone else)
import binascii, hashlib
while pubnum!=0: pubnumlist.append(pubnum%58); pubnum/=58
for l in ['123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'[x] for x in pubnumlist]:
print addy(int(hashlib.sha256('something small and easy to remember but not easy to guess').hexdigest(),16))
The code uses the ecdsa library which can be found here
The address function takes a private key and returns the corresponding bitcoin address.
The last two lines have some practical uses of the address function. Since the sha256 hash function returns a 256 bit long value, it can be used to generate a private key. This is useful if you want to have a bitcoin address and private key that you can remember without having to write it down anywhere, or if you want to use a file that you have on your computer as the key. When you want to spend the coins that you have in that address, all you have to do is use the same function to generate the private key and address.WARNING #1:
using a file that you have on your computer or a short sentence to generate a private key / address pair makes it a lot easier for an attacker to guess your private key. Instead of having to try 2^256 possibilities, they only have to try the files on your computer one by one, or your favorite book/game/your birthday...WARNING #2:
I just made this script today and I'm fairly new to bitcoin. Use at your own risk !woooo five posts i'm outta here