App-KamstrupKemSplit

 view release on metacpan or  search on metacpan

bin/kamstrup-kem-split.pl  view on Meta::CPAN

#! /usr/bin/env perl
# PODNAME: kamstrup-kem-split.pl
# ABSTRACT: Split encrypted KEM file input from the Kamstrup backend into separate XML files with device information
our $VERSION = '0.007'; # VERSION	

use Modern::Perl '2022';
use App::KamstrupKemSplit;
use Log::Log4perl qw(:easy);
use XML::Simple;
use Getopt::Long;
use Pod::Usage;
my ( $key, $verbose, $help, $man, $config, $kemformat, $show_version );

# Default values
$verbose = 0;
$kemformat = 2; # Default to KEM file format type 2

# Get the command line options
GetOptions(
	'help|?|h'  => \$help,
	'man'       => \$man,
	'v|verbose' => \$verbose,
	'key=s'     => \$key,
	'config=s'  => \$config,
	'kem=s'     => \$kemformat,
	'version'   => \$show_version
) or pod2usage(2);

pod2usage(1) if (defined $help);

if ($verbose) {
	Log::Log4perl->easy_init($DEBUG);
	INFO "Starting in verbose mode";
} else {
	Log::Log4perl->easy_init($INFO);
}

if (defined $show_version) {
	my $version = $main::VERSION // 'dev';
	INFO "This is kamstrup-kem-split version " . $version;
	exit(0);
}

pod2usage(1) if (!defined $ARGV[0]);

# Open the config file
my $orders;
$orders = read_config($config) if (defined $config);

# Unzip it
my $kem_file = unzip_kem( $ARGV[0] );

# Decode the kem file from the archive
my $xml = decode_kem( $kem_file, $key, $kemformat);


# Remove the unzipped file
unlink $kem_file;

# If we are parsing KEM2 file we dump the XML and stop here
INFO "KEMformat is '$kemformat'";
if ($kemformat == 2) {
	write_kem2_xml_output($xml);
	exit(0);
}

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.402 second using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )