Net-NSCA-Client
view release on metacpan or search on metacpan
bin/send_nsca view on Meta::CPAN
# Get the input delimiter
my $delimiter = $args{input_delimiter};
if (!defined $delimiter) {
confess 'An input delimiter must be provided to read_stdin()';
}
# Get the different values from the line
my ($hostname, $service, $status, $message)
= split m{$delimiter}msx, $line, $INPUT_FIELD_COUNT;
# Return a HASH of the format for Net::NSCA::Client->send_report
return (
hostname => $hostname,
message => $message,
service => $service,
status => $status,
);
}
lib/Net/NSCA/Client/Connection/TLS.pm view on Meta::CPAN
# Return the encrypted byte stream
return $encrypted_byte_stream;
}
###############################################################################
# PRIVATE METHODS
sub _xor_encrypt {
my ($self, $byte_stream, $iv) = @_;
# Make a byte array of the IV
my @byte_iv = split m{}msx, $iv;
# Make a byte array of the password if there is a password
my @byte_password = $self->has_password ? (split m{}msx, $self->password) : ();
# Convert the byte stream into an array for manipulation
my @byte_stream = split m{}msx, $byte_stream;
foreach my $byte_index (0..$#byte_stream) {
# Foreach byte in the byte stream, XOR the byte with the IV
$byte_stream[$byte_index] ^= $byte_iv[$byte_index % scalar @byte_iv];
if ($self->has_password) {
# If there is a password, XOR the byte with the password
$byte_stream[$byte_index] ^= $byte_password[$byte_index % scalar @byte_password];
}
}
( run in 0.727 second using v1.01-cache-2.11-cpan-71847e10f99 )