Project

ruar

0.0
No commit activity in last 3 years
No release in over 3 years
Pack your Ruby code for distribution
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 5.14.3
~> 13.0.3
~> 1.9.0
~> 0.5.1
 Project Readme

ruar

Tar-like Archive for RIEN

CI Tests Build

This GEM is still in development, please use the latest git dev branch

Usage

require 'ruar'
require 'tmpdir'

# Serialize it
# file /tmp/plain.ruar => data
archive = File.join(Dir.tmpdir, 'plain.ruar')
Ruar::Serialize.plain('./test/sample', archive)

# Setup
Ruar.setup(
  archive: archive
).activate

# Require from /tmp/plain.ruar
require 'dir/file'

# require 'your_file', from: [:both, :ruar, :local]
# require_relative 'your_file', from: [:both, :ruar, :local]
# load 'your_file', from: [:both, :ruar, :local]
#
# Notice: Currently we don't support autoload from ruar

# Here you go

AEAD

Encrypt

require 'ruar'
require 'tmpdir'

auth_data = Base64.encode64('nekomimi')
Ruar.cipher.setup(auth_data: auth_data)

archive = File.join(Dir.tmpdir, 'aead.ruar')
Ruar::Serialize.aead('./test/sample', archive)

Then you will get /tmp/aead.ruar.setup

Ruar.cipher.setup(
  iv: 'niNGDaPcFiD8eKdb',
  key: 'I0LpzLx3GuU19F5EOwTbfZJ6pYOlH4Pbumm9SolLJv8=',
  auth_data: 'bmVrb21pbWk=',
  tag: 'nN6rCnd5SmZaoTdpmUEjtw==')
Ruar.cipher.enable

Decrypt

require 'lib/ruar'
require 'tmpdir'

# Decryption Setup
Ruar.cipher.setup(
  iv: 'niNGDaPcFiD8eKdb',
  key: 'I0LpzLx3GuU19F5EOwTbfZJ6pYOlH4Pbumm9SolLJv8=',
  auth_data: 'bmVrb21pbWk=',
  tag: 'nN6rCnd5SmZaoTdpmUEjtw==')
Ruar.cipher.enable

archive = File.join(Dir.tmpdir, 'aead.ruar')
Ruar.setup(archive: archive).activate

# Setup
Ruar.setup(
  archive: archive
).activate

# Require from /tmp/aead.ruar
require 'dir/file'

Format

+--------+-------+--------+-----+--------+
| Header | Index | File 0 | ... | File x |
+--------+-------+--------+-----+--------+

Header

+-------------------------------------------------------------+
|                            Header                           |
+-------------------------------+-----------------------------+
| major_version:      uint32_t  | minor_version:     uint32_t |
+-------------------------------+-----------------------------+
| patch_version:      uint32_t  | platform:          uint32_t |
+-------------------------------+-----------------------------+
| encryption_flags:   uint32_t  | compression_flags: uint32_t |
+-------------------------------+-----------------------------+
| index_start(octet): uint32_t  | index_size(octet): unit32_t |
+-------------------------------+-----------------------------+
| index_checksum:     uint32_t  | header_checksum:   uint32_t |
+-------------------------------+-----------------------------+
|                            padding:                         |
|                           24 octets                         |
+-------------------------------+-----------------------------+

Index

{
   "files": {
      "tmp": {
         "files": {}
      },
      "usr" : {
         "files": {
           "bin": {
             "files": {
               "ls": {
                 "offset": "0",
                 "size": 100,
                 "executable": true
               },
               "cd": {
                 "offset": "100",
                 "size": 100,
                 "executable": true
               }
             }
           }
         }
      },
      "etc": {
         "files": {
           "hosts": {
             "offset": "200",
             "size": 32
           }
         }
      }
   }
}