Re: Is there a way to Encrypt entire folders with BGT?

Sure.
One could encrypt each file individually, or could encrypt them after packing them.
(IIRC, the encryption scheme changed after the Perilous Hearts demo, but I'm not sure about that. I know it changed at one point to something more secure.)


Here's an example. I'm literally just adding one line to my pack_all example:

// Pack all files in a certain directory, recursive.
// This probably needs to be in its own script; pack everything separately from the game, otherwise it will do weird things when someone tries to play it.

// Both parameters here have a default value, so you can just call pack_all().close() and that's everything. You might try pack_all("sounds") if you only want the sounds folder, for example.

pack_file@ pack_all(string top="", pack_file@ ret=null) {
 if(@ret==null) {
  pack_file temp;
  @ret=temp;
  ret.create("sounds.dat");
 }

// Formatting:
if((top!="")&&(string_right(top, 1)!="/")&&(string_right(top, 1)!="\\")) {
 top += "/";
 }
string[] dirs=find_directories(top + "*");
string[] files=find_files(top + "*");

for(uint i=0; i<files.length(); i++) {
ret.add_file(top + files[i], top + files[i]); // The filename in the pack matches the filename on the system.
}

 for(uint i=0; i<dirs.length(); i++) {
 @ret=pack_all(top + dirs[i], ret); // Since ret is a handle, we shouldn't need to save it, but if this doesn't work, try adding @ret= to the start of this line.
}

return ret;
}


void main() {
// Example, packing everything in ./sounds
pack_all("sounds/").close();
file_encrypt("sounds.dat", "sounds2.dat", "best encryption key ever!");
}

If you wanted to encrypt something other than sounds, and use a file other than sounds.dat, you might do something like this:

pack_file temp;
pack_file@ pack=temp; // Just because we'll be passing it around to functions.
pack.create("data.temp"); // It's a temp because we're going to encrypt it.
pack_all("", pack);
pack.close();
file_encrypt("data.temp", "data.dat", "super awesome key of safety+4");


To use the pack later, you'd need to decrypt it first, though, which could be a problem.
An alternative would be to encrypt all your files separately, then pack the encrypted files. You'd need something like the pack_all function to do this, just encrypting instead of packing. The advantage to changing it to work that way would be that you could access the files more easily without the security risk of unpacking everything where a cheater might find it.
That, and the sound engine allows you to use a pack and set an encryption key, but IIUC it only works if the files are encrypted separately.

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Orin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector

Reply via email to