OK, so it looks like you have some of the framework done. Looking at the Crypt::CBC page on MetaCPAN, you're not encrypting the fields correctly. You need to get each line of the file, split it into fields, encrypt two of the fields, and write the fields out to a new file.
PS, Always, always, ALWAYS use strict and use warnings.use autodie; # Using this module means open and close errors are # handled nicely. my @affected_fields = qw/0 8/; .. # Figure out the input and the output file names here .. .. open ( my $input_fh, '<', $input_file ); open ( my $output_fh, '>', $output_file ); while ( <$input_file> ) { my @fields = split ( /,/ ); if ( $type =~ /^en(crypt)?$/ ) { foreach ( @affected_fields ) { $fields[ $_ ] = $cipher->encrypt( $fields[ $_ ] ); } } else { # I would prefer to use an elsif here, but # you could catch this during parameter checking. foreach ( @affected_fields ) { $fields[ $_ ] = $cipher->decrypt( $fields[ $_ ] ); } } print $output_fh join (',', @fields ) . "\n"; } close ( $input_fh ); close ( $output_fh );
In reply to Re: Using Cypher::CBC to encrypt fields in a file - Need Monk Help
by talexb
in thread Using Cypher::CBC to encrypt fields in a file - Need Monk Help
by perlc1ph3r
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |