»   »   »

Perl and The Tiny Encryption Algorithm (tea)

I've always liked messing with data encryption in one form or other. Although tea (Tiny Encryption Algorithm) is a little out-dated and has a few weaknesses, it is a good one to use as a learning tool.

I wrote a Perl script to put together what I learned. It's quite a useful little script that can encrypt single files or directories (although I would make sure the folder is less than 1GB or things will get slow).

Here's the core call that does the work;

To encrypt:

write_file( $out, {binmode => ':raw'}, &encrypt ($indata, $key) );

To decrypt:

write_file( $tempfile, {binmode => ':raw'}, &decrypt ($indata, $key) ) ;

The full script is available here.

If you're interested in more encryption and Perl examples, you could start with whohee - my file encryption using variable encryption algorithms.

© Roqet :: 2022-03-01 16:07:35