Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Web Confidential to KeePassX
#!/usr/bin/env ruby
# Usage:
# 1) Save as something.rb on Desktop. Optionally update the date on the line
# that beings with "time = " if you want the creation date to be correct in
# KeePassX.
# 2) Run in Terminal: chmod 777 ~/Desktop/something.rb
# 3) Run in Terminal: ~/Desktop/something.rb web_confidential_export.txt
# 4) Import the resulting export.xml into KeePassX
# 5) Use the "srm" command to delete the plaintext files containing passwords
# (the Web Confidential export and the file you imported into KeePassX).
# For more information on "srm", run "man srm".
require 'rubygems'
require 'htmlentities'
coder =
passwords =
passwords = passwords.split("\r")
passwords.each_with_index {|p,i| passwords[i] = p.split("\t")}
time = "2010-06-14T19:21:00"
xml = <<EOF
count = 1
passwords.each do |p|
(1..5).each {|i| p[i] = coder.encode(p[i]) || ""}
entry = <<EOF
xml = xml + entry
count = count + 1
xml = xml + "</group>""export.xml", 'w') {|f| f.write(xml)}
puts "#{count} exported"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment