I've been a long time user of Passpack. After F-Secure released it's Key password manager (http://www.f-secure.com/en/web/home_global/key) I decided to give it a shot, and found it very appealing due to it's simplicity. And after using it for a while I decided give up Passpack - there was a problem though... F-Secure Key did not support import of CSV or such formats. Fortunately, it supports few other formats, so it is possible to convert from Passpack's CSV to one of the other formats. Below is the script I wrote for the task. Basically, you can format just about any export format to the simple CSV format:
Usage: fskey.py input.csv > output.xml And output.xml is ready to be imported in F-Secure Key. #!/usr/bin/python # -*- coding: utf-8 -*- import lxml.etree import sys import csv if len( sys.argv ) != 2: print '%s csv.txt' % sys.argv[0] sys.exit() def utf8_csv_reader( utf8_data, dialect = csv.excel, **kwargs ): csv_reader = csv.reader( utf8_data, dialect = dialect, **kwargs ) for row in csv_reader: yield [ unicode( cell, 'utf-8' ) for cell in row ] root = lxml.etree.Element( 'passwordsafe' ) with open( sys.argv[1], 'rb' ) as csvfile: lines = utf8_csv_reader( csvfile, delimiter = ',', quotechar = '"' ) for line in lines: ( name, uid, pwd, link, tags, note, email ) = line notes = [] if len( email ) > 0: notes.append( 'Email: %s' % ( email ) ) if len( note ) > 0: notes.append( note ) entry = lxml.etree.SubElement( root, 'entry' ) lxml.etree.SubElement( entry, 'title' ).text = name lxml.etree.SubElement( entry, 'url' ).text = link lxml.etree.SubElement( entry, 'username' ).text = uid lxml.etree.SubElement( entry, 'password' ).text = pwd lxml.etree.SubElement( entry, 'notes' ).text = '\n\n'.join( notes ) print lxml.etree.tostring( root, pretty_print = True, xml_declaration = True, encoding = 'utf-8' )
|
Blog >