The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Archive::Tyd - Perl extension for simple file archiving.


  use Archive::Tyd;

  my $tyd = new Archive::Tyd (password => 'secret password');

  # Load an archive.
  $tyd->openArchive ("./archive.tyd");

  # Add a file.
  $tyd->addFile ("./secret image.jpg");

  # Write the archive.
  $tyd->writeArchive ("./archive.tyd");

  # Read the secret rules.
  my $rules = $tyd->readFile ("rules.txt");


Tyd is a simple archiving algorith for merging multiple files together and encrypting the results, hence a password-protected archive.

Tyd Does: Reading and writing of encrypted Tyd archives and file operations within.

Tyd Does: Load all files into memory. Tyd is not good as a storage device for a large quanitity of large files. Tyd is best for keeping small text files and graphics together (maybe to keep a spriteset and definitions for a game?)

Tyd Does Not: support directories within the archive, compression of files, and many other things that WinZip and GZip support.



Creates a new Tyd object. You can pass in defaults here (such as password and debug).

password (PASSWORD)

(Re)define the password to be used. The default password is 'default'.

openArchive (FILE)

Open the archive and decrypt it with the password. You can load multiple archives with one object, and even change the password between each one.

writeArchive (FILE)

Writes all the files to the archive using the current password.

addFile (FILEPATH)

Adds FILEPATH to the archive. The file will later be called by its file name, not the whole path (i.e. just "readme.txt", not "C:/secret folder/readme.txt")

deleteFile (FILENAME)

Delete the file from the archive.

readFile (FILENAME)

Read the file. It will return the binary data of the file (which you can then save to another file or whatever).


Returns an array of each file in the archive.

filename (FILEPATH) *Internal

Takes a file path and returns its name

cipher ([FORCE]) *Internal

Creates the ciphering object. Supply FORCE for it to recreate the object forcefully (used when you call the password method to change the password).


I made this module to use with games I make which will allow users to create their own quests and store ALL of their data (maps, sound effects, tilesets, etc) into a single, password-protected file.

This module was not meant to compress files in any way. The resulting archive should be little more than the original size of all the files archived inside of it. This algorithm is only for tying files together and password protecting them.


The algorithm is quite simple. When not encrypted, the archive file would read like this:


Once the unencrypted file is ready, the entire thing is encrypted using Crypt::CipherSaber with the password provided and written to the archive.


  Version 0.02
  - Fixed some major bugs. In 0.01 version, reading an archive Tyd file and then
    re-archiving it from the files in-memory, would for some reason corrupt the file.
    This has been repaired.
  - Carriage Returns are now filtered in and out correctly.
  - Included Tydra--a Perl/Tk interface to Tyd Archive Viewing.

  Version 0.01
  - Initial Release




C. J. Kirsle, <kirsle "@">


Copyright (C) 2005 by C. J. Kirsle

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.