decrypt 838 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. my $file;
  5. if ( ! defined $ARGV[0] ) {
  6. print "Enter file path to decrypt: ";
  7. my $input = <STDIN>;
  8. chomp $input;
  9. $file = $input;
  10. } else {
  11. # Expects full path of file
  12. $file = $ARGV[0];
  13. }
  14. if ( ! -f $file ) { die "File argument must be a plain file, $file is not a plain file or it cannot be found, exiting...\n" };
  15. # Get rid of .gpg
  16. my $newFileName = $file;
  17. for ( 0 .. 3 ) {
  18. my $char = chop($newFileName);
  19. }
  20. print "new filename is $newFileName\n";
  21. system("gpg -o $newFileName -d $file") == 0 or die "Something went wrong with GPG, I didn't decrypt the file...";
  22. print "Looking for decrypted file..\n";
  23. if ( -f $newFileName ) {
  24. print "Unencrypted file is at: $newFileName\n";
  25. } else {
  26. print "Something went wrong? I couldn't find the decrypted file, maybe check the dir?\n";
  27. exit 1;
  28. }