decrypt(3pm)

πŸ’– decrypt(3pm) β€” Filter::decrypt πŸ’–

okay bestie, welcome to the User Contributed Perl Documentation corner of the internet, where we're talking about a little thing called Filter::decrypt from the 3pm manual section. sit down, grab a strawberry, and let's get into it πŸ“βœ¨


✨ NAME ✨

Filter::decrypt β€” it's literally a template for a decrypt source filter. that's the whole vibe.


🌸 SYNOPSIS 🌸

use Filter::decrypt ;

yes queen, that's it. one line. iconic.


πŸ¦‹ DESCRIPTION πŸ¦‹

so this is a sample decrypting source filter. and the way that it's fully functional AND implements a very simple decrypt algorithm? love that for us.

BUT. and this is a big but πŸ’… β€” it is not intended to be used as it is supplied. nope. think of it as a template β€” you take it, you combine it with a proper decryption algorithm, and then you've got yourself your very own decryption filter. main character energy, but you have to do the work first, iykyk.


😭 WARNING 😭

okay fam, serious moment. listen up because this part matters.

It is important to note that a decryption filter can never provide complete security against attack. like, ever. at some point the parser within Perl needs to be able to scan the original decrypted source. which means β€” at some stage β€” fragments of the source will exist in a memory buffer. yeah. it's giving exposed. 😬

Also, with the introduction of the Perl Compiler backend modules, and the B::Deparse module in particular, using a Source Filter to hide source code is becoming an increasingly futile exercise. not me being dramatic, that's literally what it says.

The best you can hope to achieve by decrypting your Perl source using a source filter is to make it unavailable to the casual user. that's the ceiling. that's the dream. okay?

Given that proviso, there are a number of things you can do to make life more difficult for the prospective cracker. bestie, consider this your checklist:

  1. Strip the Perl binary to remove all symbols. bye bye clues βœ‚οΈ
  2. Build the decrypt extension using static linking. If the extension is provided as a dynamic module, there is nothing to stop someone from linking it at run time with a modified Perl binary. so don't do that.
  3. Do not build Perl with -DDEBUGGING. If you do then your source can be retrieved with the -DP command line option. no cap, that's a whole leak.

The sample filter contains logic to detect the DEBUGGING option. so at least it's trying 🫢

  1. Do not build Perl with C debugging support enabled. just don't.
  2. Do not implement the decryption filter as a sub-process (like the cpp source filter). It is possible to peek into the pipe that connects to the sub-process. and bestie, people will peek. πŸ‘€
  3. Check that the Perl Compiler isn't being used.

There is code in the BOOT: section of decrypt.xs that shows how to detect the presence of the Compiler. Make sure you include it in your module. do not skip this step, I'm begging πŸ™ˆ

Assuming you haven't taken any steps to spot when the compiler is in use and you have an encrypted Perl script called myscript.pl, you can get access the source code inside it using the perl Compiler backend, like this

perl -MO=Deparse myscript.pl

Note that even if you have included the BOOT: test, it is still possible to use the Deparse module to get the source code for individual subroutines. so like… yeah. πŸ’€

  1. Do not use the decrypt filter as-is. The algorithm used in this filter has been purposefully left simple. that was on purpose, bestie, it's a template for a reason.

If you feel that the source filtering mechanism is not secure enough you could try using the unexec/undump method. See the Perl FAQ for further details. that's your next stop, bestie πŸš€

fr fr, if you're relying on a source filter for real security, please go read that FAQ. the vibe check says your secrets are not as safe as you think.

πŸ’… EXAMPLES πŸ’…

See /usr/share/doc/libfilter-perl/examples/decrypt/ for examples of encryption and decryption scripts using this filter. go look, they're right there, literally free ✨


πŸ‘‘ AUTHOR πŸ‘‘

Paul Marquess β€” the icon, the legend, the author. periodt.


πŸŽ€ DATE πŸŽ€

19th December 1995. yes, a vintage. she's been serving since the 90s πŸ’œ


and that's the whole page, bestie! this gem shipped with perl v5.42.3 on 2026-08-19 β€” so if you're reading this, you're holding a genuinely retro little template that's still riding along in modern perl. obsessed. take care of her, don't use her as-is, and stay safe out there πŸ¦‹πŸ’–βœ¨

πŸ“¦ where this page comes from