#!/usr/bin/python

# Copyright (C) 2010 Laurent Fousse <laurent@komite.net>.
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.

import getpass
from hashlib import md5
import sys
import string

alpha = (string.ascii_letters + string.digits) * 3 + '~*#+/!_' * 10

pw = getpass.getpass("Passphrase:")
u = md5()
u.update(pw.encode('utf-8'))
u.update(sys.argv[1].encode('utf-8'))

print(''.join([alpha[u.digest()[x]] for x in range(16)])[:8])
