Class: Encrypth::Archiver
- Inherits:
-
Object
- Object
- Encrypth::Archiver
- Defined in:
- lib/encrypth/archiver.rb
Instance Method Summary collapse
-
#decrypt_to_directory(archive_path, destination) ⇒ Object
Дешифрует архив и извлекает файлы в указанную директорию.
-
#encrypt_files(files, archive_path) ⇒ Object
Шифрует содержимое файлов и сохраняет его в виде зашифрованного архива.
-
#initialize(cipher) ⇒ Archiver
constructor
A new instance of Archiver.
Constructor Details
#initialize(cipher) ⇒ Archiver
Returns a new instance of Archiver.
8 9 10 |
# File 'lib/encrypth/archiver.rb', line 8 def initialize(cipher) @cipher = cipher end |
Instance Method Details
#decrypt_to_directory(archive_path, destination) ⇒ Object
Дешифрует архив и извлекает файлы в указанную директорию
20 21 22 23 24 |
# File 'lib/encrypth/archiver.rb', line 20 def decrypt_to_directory(archive_path, destination) encrypted = File.binread(archive_path) tar_content = @cipher.decrypt(encrypted) extract_tar_archive(tar_content, destination) end |
#encrypt_files(files, archive_path) ⇒ Object
Шифрует содержимое файлов и сохраняет его в виде зашифрованного архива
13 14 15 16 17 |
# File 'lib/encrypth/archiver.rb', line 13 def encrypt_files(files, archive_path) tar_content = create_tar_archive(files, archive_path) encrypted = @cipher.encrypt(tar_content) File.binwrite(archive_path, encrypted) end |