ruby KeePass 2 XML导出到1Password Mac CSV导入http://learn2.agilebits.com/1Password4/Mac/en/KB/import.html
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby KeePass 2 XML导出到1Password Mac CSV导入http://learn2.agilebits.com/1Password4/Mac/en/KB/import.html相关的知识,希望对你有一定的参考价值。
require 'csv'
require 'open-uri'
require 'nokogiri'
file = "keepass.xml"
doc = Nokogiri::XML::Document.parse(open(file)) do |config|
config.noblanks
end ; nil
entries = []
doc.css('Group > Entry').each do |entry|
attributes = {}
attributes["GroupName"] = entry.parent.css('> Name').text
entry.css('String').each do |string|
unless string.css_path.include?('History')
key = string.css('Key').text
value = string.css('Value').text
attributes[key] = value
end
end
entries << attributes
end
content = entries.map do |entry|
[
"#{entry['GroupName']} #{entry['Title']}",
entry['URL'],
entry['UserName'],
entry['Password'],
entry['Notes'],
]
end
CSV.open("1password.csv", "wb") do |csv|
content.each do |row|
csv << row
end
end
以上是关于ruby KeePass 2 XML导出到1Password Mac CSV导入http://learn2.agilebits.com/1Password4/Mac/en/KB/import.html的主要内容,如果未能解决你的问题,请参考以下文章
Ruby:CSV到XML(版本2)
text #安装KeePass 2
keepass怎么用
KeePass使用方法
keepass和eraser产品安全分析(实验报告)
keepass和eraser产品安全分析(实验报告)