I wrote a small/dirty python script that allows me to use an arbitrary value (like a string) as a "public key" in order to create a Bitcoin address.
This is the script:
#Wyager's quick and dirty arbitrary public key hasher
import binascii
import sys
import hashlib
code_string = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
###
pubkey = sys.argv[1] #the "public key" is the first command line argument
###
sha_pubkey = hashlib.sha256(pubkey).digest()# sha of the "public key"
###
ripe = hashlib.new("ripemd160")
ripe.update(sha_pubkey)
ripe_pubkey = ripe.digest()#ripemd of that
###
versioned_ripe_pubkey = "\x00" + ripe_pubkey#add a 00 to the beginning
###
sha_ripe_1 = hashlib.sha256(versioned_ripe_pubkey).digest()#sha that once
sha_ripe_2 = hashlib.sha256(sha_ripe_1).digest()#sha it twice
checksum_4_bytes = sha_ripe_2[0:4] #take the first 4 bytes of that
###
ripemd_and_checksum = versioned_ripe_pubkey + checksum_4_bytes#stick that on the end of the ripemd
###
integer_result = int(binascii.hexlify(ripemd_and_checksum), 16)
base58check_result = ""
while(integer_result > 0):#base58check encode that
remainder = integer_result % 58
integer_result = integer_result / 58
base58check_result = base58check_result + code_string[remainder]#insert the base58 values
i = 0
while(ripemd_and_checksum[i]=="\x00"): #append a "1" for every leading zero byte
base58check_result = base58check_result + "1"
i = i + 1
###
reversechars = list(base58check_result)#flip the string around to make it big endian
reversechars.reverse()
base58check_result = ''.join(reversechars)
###
print base58check_result
I don't use python very often, so forgive my bad form.
My intention here was to make a simple system that allowed for proof of copyright or whatever. You treat your secret string/document as a "public key", and send money to the corresponding address, so it shows up on the blockchain. If you ever need to prove that you knew the string/document at some point, you can simply point to the transaction that has that address on the blockchain. This gives you a strong hash+timestamp. This is obviously not the only way to do this, this was just for fun.
Anyway, what I noticed was that someone else obviously had the same idea. I ran this script using "hello" as the public key, and that produces an address of 1HeqNjAst5TCQ63F7xhjg6bcTbDKrRk7sH. According to
http://blockexplorer.com/address/1HeqNjAst5TCQ63F7xhjg6bcTbDKrRk7sH, someone has already sent money to "hello". I wonder what other addresses out there like this exist?