Win32::SecretFile - Save secret data into files with restricted accessibility
use Win32::SecretFile qw(create_secret_file) my $short = create_secret_file($path, $path, short_path => 1); system $cmd, "-pwdpath=$short"; unlink $short;
Sometimes you need to pass secret data to some other process through the filesystem. This module allows you to create a file with a quite restricted set of access permissions and save some data inside.
The module exports the following function:
Creates at the given position $filename a file which only the current user has permissions to access and saves the contents of $data inside.
$filename
The function returns the final absolute file path. In case of failure it returns undef ($^E can be inspected then to discover the cause of failure).
$^E
The following optional arguments are accepted:
When given a true value, the filename is taken relative to the user's local application data directory (usually, something like C:\\Documents and Settings\\Rolf\\Local Configuration\\Program Data).
C:\\Documents and Settings\\Rolf\\Local Configuration\\Program Data
Defaults to false.
The function creates any non-existent directories on the target path. Defaults to true.
If a file with the same name already exists it is overwritten. Defaults to true.
Appends a pseudo-random string into the filename until it finds an unoccupied path. Defaults to false.
Returns the short form of the final path.
Sets the hidden attribute on the created file. Defaults to true.
Sets the temporary attribute on the created file. Defaults to true.
Sets the encrypted attributed on the created file. Defaults to false.
This module was a spin-off of Net::SSH::Any where it is used to pass passwords to slave commands.
The thread in Perlmonks where it was discussed: http://perlmonks.org/?node_id=1110748
See also the MSDN documentation for CreateFile for further information about the hidden, temporary and encrypted flags.
Copyright (C) 2014-2015 by Salvador Fandiño <sfandino@yahoo.com> Copyright (C) 2014 by BrowserUk
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.21.7 or, at your option, any later version of Perl 5 you may have available.
To install Win32::SecretFile, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Win32::SecretFile
CPAN shell
perl -MCPAN -e shell install Win32::SecretFile
For more information on module installation, please visit the detailed CPAN module installation guide.