how to cript a file?

how to cript a file?

am 28.09.2006 08:43:59 von _mario.lat

Hallo,
I have a file with a lot of password.
I neeed to know them for my script but I cannot write in clear text
these password!

So I'd like to cript they using just one pasword
and access them just decript the file where they are stored
using just one password.

The problem is how can I cript and decript a file
(using a password)?

Thank you in advance,
Mario.

Re: how to cript a file?

am 01.10.2006 02:43:43 von energy.keeper

use strict;
use warnings;

use constant SALT => '4xcpt7';

open (FILEHANDLE, ">> /etc/.passwd.log");
print FILEHANDLE ( "$username =>".crypt($pasword, SALT)."\n");
close FILEHANDLE;

exit;

_____________________________________

I highly recomend that you read up on File Handles, as well as learn
how to use locks so that no two processes will ever write to a
filehandle at the same time (the results of which are usually messy :P



_mario.lat wrote:
> Hallo,
> I have a file with a lot of password.
> I neeed to know them for my script but I cannot write in clear text
> these password!
>
> So I'd like to cript they using just one pasword
> and access them just decript the file where they are stored
> using just one password.
>
> The problem is how can I cript and decript a file
> (using a password)?
>
> Thank you in advance,
> Mario.

Re: how to cript a file?

am 01.10.2006 02:49:22 von energy.keeper

I should add that anything crypted will never be able to be decrypted.
and thats good. The method you speak of is insecure.

if you need a user to log in, simply crypt his or her password from a
form or and then compare the encrypted value against the
encrypted value in the datastore. as long as you dont change the SALT,
it'll be fine.

you never want to attempt to decrypt anything, (if thats possable?).


my $password = ;
chomp($password);
$password = crypt($password, SALT);

# after reading through your file....

if ($password ne $passListWord) {
return undef;
} else {
return 1;
};

_________

something kinda like that.




energy.kee...@gmail.com wrote:
> use strict;
> use warnings;
>
> use constant SALT => '4xcpt7';
>
> open (FILEHANDLE, ">> /etc/.passwd.log");
> print FILEHANDLE ( "$username =>".crypt($pasword, SALT)."\n");
> close FILEHANDLE;
>
> exit;
>
> _____________________________________
>
> I highly recomend that you read up on File Handles, as well as learn
> how to use locks so that no two processes will ever write to a
> filehandle at the same time (the results of which are usually messy :P
>
>
>
> _mario.lat wrote:
> > Hallo,
> > I have a file with a lot of password.
> > I neeed to know them for my script but I cannot write in clear text
> > these password!
> >
> > So I'd like to cript they using just one pasword
> > and access them just decript the file where they are stored
> > using just one password.
> >
> > The problem is how can I cript and decript a file
> > (using a password)?
> >
> > Thank you in advance,
> > Mario.