On Thu, Mar 03, 2011 at 05:23:43PM -0700, Aaron Toponce wrote: > So, has anyone successfully implemented Hashcash into Mutt, and if so, how?
Here is what I came up with. It's a Python script that runs as my default editor. The script calls Vim, after which, it parses the headers and adds the necessary tokens. I haven't found any bugs yet, but I'm sure I will soon enough. I also blogged about it here: http://pthree.org/2011/03/24/hashcash-and-mutt/ Now to start working on the verification process. I figure I can use $display_filter for that, and just not filter anything, but execute another Python script. Anyway, thought I'd post an update. -- . o . o . o . . o o . . . o . . . o . o o o . o . o o . . o o o o . o . . o o o o . o o o
#!/usr/bin/env python import csv import fileinput import rfc822 import subprocess import sys subprocess.call("vim %s" % sys.argv[1], shell=True) file = open(sys.argv[1], 'r') headers = rfc822.Message(file) to_emails = headers.getaddrlist("To") cc_emails = headers.getaddrlist("Cc") email_addrs = [] tokens = [] # Harvest all email addresses from the header for email in to_emails: email_addrs.append(email[1]) for email in cc_emails: email_addrs.append(email[1]) # Remove duplicate emails from the list, requires Python 2.5 and later email_addrs = list(set(email_addrs)) # Check if an appropriate token is already generated for the mail if headers.has_key("X-Hashcash"): for list in headers.getheaders("X-Hashcash"): email_addrs.remove(list.split(":")[3]) if headers.has_key("Hashcash"): for list in headers.getheaders("Hashcash"): email_addrs.remove(list.split(":")[3]) # Call the hashcash function from the operating system to mint tokens for email in email_addrs: t = subprocess.Popen("hashcash -m %s -X -Z 2" % email, shell=True, stdout=subprocess.PIPE) tokens.append(t.stdout.read()) # Write the newly minted tokens to the header f = fileinput.FileInput(sys.argv[1], inplace=1) for line in f: line = line.strip() if f.lineno() == 1: for token in tokens: print token, print line continue else: print line file.close()
signature.asc
Description: Digital signature