项目作者: nikhil10marvel

项目描述 :
A small, in development, minimalistic archive format that supports xz and lzma2 compression as well basic encryption
高级语言: Java
项目地址: git://github.com/nikhil10marvel/minAR.git
创建时间: 2018-04-04T14:27:48Z
项目社区:https://github.com/nikhil10marvel/minAR

开源协议:

下载


minAR

A small, in development, minimalistic archive format that supports xz and lzma2 compression as well basic encryption

minAR is in no way a fully fledged archive format, it is merely a format that encapsulates multiple files, compressing them in the process and finally encrypting the end result.

The JavaDoc is here

Basic usage

1. Creating an archive

  1. MinAR.toggleFlags(MinAR._default_no_enc);
  2. MinAR.outputArchive("directory", "my_archive");

This creates an archive of the ‘directory’ called my_archive.mar.
The archive contains the compressed contents of ‘directory’.

The flags toggled here, enable compression and do not support encryption.
For more information, please refer the JavaDoc

2. Extracting an archive

To extract the above created archive, the following should be used:

  1. MinAR.toggleFlags(MinAR._default_no_enc);
  2. MinAR.extractArchive("my_archive.mar", "some_dir", null);

The same flags that were toggled on, while creating the archive must be
toggled on, with the exception of KEY_IS_FILE and KEY_IS_STRING as
they play no roles in the creation of the archive.

extractArchive(...) method will take a third parameter, which is
the key(type: String), but it depends on the flags set.

The key is mandatory in case of encryption (obviously) and is absolutely unnecessary if the archive is not encrypted
For more information, please refer the JavaDoc for extractArchive(...) method

Flags(MinAR.FLAG)

Optionally Certain flags can be set or toggled on before operations to improve the created archive.
When certain flags are activated, the files will be compressed before being archived.
When certain other flags are activated, the end archive will be encrypted.

















FLAGFUNCTION
COMPRESSEDCompresses each file before archiving
ENCRYPTEDEncrypts the generated archive
KEY_IS_FILEChanges the thrid parameter, takes in a path to a file
KEY_IS_STRINGChanges the third parameter, takes the string form of the key

Code Example

  1. package test;
  2. import io.minAR.MinAR;
  3. public class Test {
  4. public static void main(String[] args){
  5. if(args.length > 0){
  6. String archive_name = args[1];
  7. if(args[0].equals("-a")){
  8. String diriectory_to_be_archive = args[2];
  9. MinAR.toggleFlags(MinAR._default_no_enc);
  10. MinAR.outputArchive(diriectory_to_be_archive, archive_name);
  11. } else if(args[0].equals("-e")){
  12. String extract_directory = args[2];
  13. MinAR.toggleFlags(MinAR._default_no_enc);
  14. MinAR.extractArchive(archive_name, extract_directory, null);
  15. }
  16. }
  17. }
  18. }

Again, for simplicity sake, _default_no_enc is used, but _default_enc_file or _default_enc_str is recommended, and the code remains largely and greatly unchanged, as mentioned above.
See test.Test which implements encryption, using _default_enc_file