python: Generating user passwords for the Abyss Webserver

Translation of the original in Catalan. Read it in: CatalàCastellano

The Abyss Webserver stores users and passwords in a configuration file in XML format. Well, the format in which the passwords are stored in the XML file is:

usercode = nom_usuari + ":" + plaintext_password
encoded_password = md5(base64(usercode))

Well, here comes the little trick of how to do this with python:

#!/usr/bin/env python
import md5
import base64
import re
<br>
def genera_pass_abyss(usercode):
        b64usercode = base64.encodestring(usercode)
        b64usercode = re.sub('\n','',b64usercode)
        hash = md5.new(b64usercode)
        return hash.hexdigest()
<br>
user = 'usuari1'
passw = 'password1'
usercode = user + ":" + passw
print usercode
print genera_pass_abyss(usercode)