NAME

sectools Module with security related functions.

SYNOPSIS

use sectools;

# create truly random string of N characters
my $random=sectools::randstr(64);

# create a sha256 sum of SCALAR
my $sum=sectools::sha256sum("SomethingIWantTheSumOf");

# create a md5sum of SCALAR
my $sum=sectools::md5sum("SomethingIWantTheSumOf");

# create a 128-bit xxhash sum of SCALAR
my $sum=sectools::xxhsum_file("MY_FILE_NAME");

DESCRIPTION

Collection of functions related to security, such as truly random strings and sha256- and md5- sums.

CONSTRUCTOR

No constructor in this module - separate functions.

METHODS

randstr()

Create a random string of N characters.

Accepts the following input: size. SCALAR. Optional. Defaults to 32. It sets how many random characters to generate.

The random string will only consists of charaters in a-z, A-Z and 0-9.

Returns the random SCALAR.

sha256sum()

Creates the sha256-sum of the specified SCALAR.

Accepts one input: data. SCALAR. Required. Defines the data to create a sha256 sum of.

Returns the SHA256-sum as a hex-digest.

sha256sum_file()

Creates the sha256-sum of the specified filename (SCALAR).

Accepts one input: filename with path. SCALAR. Required. Defines the file to open and calculate the sha256sum of.

Returns the sha256sum as a hex-digest or a string starting with "Error!" upon failure.

md5sum()

Creates the md5-sum of the specified SCALAR.

Accepts one input: data. SCALAR. Required. Defines the data to create a md5sum sum of.

Returns the md5-sum as a hex-digest.

md5sum_file()

Creates the md5-sum of the specified filename (SCALAR).

Accepts one input: filename with path. SCALAR. Required. Defines the file to open and calculate the md5sum of.

Returns the md5sum as a hex-digest or a string starting with "Error!" upon failure.

xxhsum_file()

Creates the xxhash-sum of the specified filename (SCALAR).

Accepts two inputs: filename (required) and type (optional). Filename must be specified with path. SCALAR. Required. Defines the file to get the xxhash of. Type defines the xxhash-version to use generating the xxhash. Valid versions are 32, 64 and 128. 128 is the default if not specified.

Returns the xxhash sum upon success or a string starting with "Error!" upon failure.