FlippyPass/tools/archive.py

64 lines
1.3 KiB
Python

"""
ARHIVE for FlipypPass
This will prepare your passwords for Import with FlippyPass
Excuse that this is written in Python...
"""
# Libraries
import sys
import json
# Variables
file_delimiter = '\v'
all_passwords = ""
# Functions
def load_json():
# Getting file path
file_path = sys.argv[1]
# Opening file
f_file = open(file_path)
f_data = f_file.read()
# Parsing json
return json.loads(f_data)
def insert_passwords(json_data):
# Global
global all_passwords
# Going through items
for item in json_data["items"]:
# Is it not valid?
if not "login" in item:
continue
# Getting important data from each
name = item["name"]
username = item["login"]["username"]
password = item["login"]["password"]
# Adding it into our password array
all_passwords += name + file_delimiter + username + file_delimiter + password + file_delimiter + "0" + file_delimiter
def save_data():
# Global
global all_passwords
# Opening file
file_data = open('archive.txt', 'w')
file_data.write("Data: " + all_passwords)
file_data.close()
def main():
# Loading json
json_data = load_json()
# Going through all passwords
insert_passwords(json_data)
# Saving the passwords
save_data()
# Entry point
main()