#!/usr/bin/perl
# Convert plain text Aegis vault format into otpauth URIs
# Copyright : https://www.fsf.org/copyleft/gpl.html
# Author : Dan Jacobson -- https://www.jidanni.org/
# Created On : Thu Apr 9 11:13:10 2020
# Last Modified On: Thu Apr 9 12:44:18 2020
# Update Count : 54
use strict;
use warnings FATAL => q(all);
use JSON;
use URI;
use URI::QueryParam;
local $/;
local $_ = <>;
my $p = decode_json $_;
for ( @{ $p->{db}->{entries} } ) {
my $u = URI->new( "otpauth://" . %{$_}{type} . "/" . %{$_}{name} );
my %i = %{ $_->{info} };
for my $k (qw/icon info name type uuid/) {
delete $_->{$k};
}
$u->query_form_hash( %$_, %i );
print $u->as_string, "\n";
}