<commit_before>-- This implementaion use for testing needs
-- It can be very slow
-- To provide your own implementation you need implement AesEncrypt interface.

-- AesEncrypt interface
-- AesEncrypt:type()    -> return 'aes'
-- AesEncrypt:mode()    -> return 1/2/3 for aes-128/aes-192/aes-256
-- AesEncrypt:version() -> return 1/2 for AE-1/AE-2
-- AesEncrypt:stream(stream, fileDesc)  return stream that convert data stream to stream like:
--               <SALT><Password verification value><Encrypted data><Authentication code>

-- stream interface
-- stream:seekable()  - if return true then you need implement get_pos/set_pos methods
-- stream:write(data) - write new chunk
-- stream:close()     - close lowlevel stream (return number of written bytes) and return number of written bytes

local function prequire(m) 
  local ok, err = pcall(require, m) 
  if not ok then return nil, err end
  return err
end

local AesFileEncrypt = prequire "AesFileEncrypt" or prequire "ZipWriter.encrypt.aes.AesFileEncrypt"

local rand_bytes<commit_msg>Raise error if aes module can not load AesFileEncrypt module<commit_after>-- This implementaion use for testing needs
-- It can be very slow
-- To provide your own implementation you need implement AesEncrypt interface.

-- AesEncrypt interface
-- AesEncrypt:type()    -> return 'aes'
-- AesEncrypt:mode()    -> return 1/2/3 for aes-128/aes-192/aes-256
-- AesEncrypt:version() -> return 1/2 for AE-1/AE-2
-- AesEncrypt:stream(stream, fileDesc)  return stream that convert data stream to stream like:
--               <SALT><Password verification value><Encrypted data><Authentication code>

-- stream interface
-- stream:seekable()  - if return true then you need implement get_pos/set_pos methods
-- stream:write(data) - write new chunk
-- stream:close()     - close lowlevel stream (return number of written bytes) and return number of written bytes

local function prequire(m) 
  local ok, err = pcall(require, m) 
  if not ok then return nil, err end
  return err
end

local AesFileEncrypt = assert(prequire "AesFileEncrypt" or prequire "ZipWriter.encrypt.aes.AesFileEncrypt")

local rand_bytes
{'fraction_non_alphanumeric': 0.09621672115833722, 'fraction_numerical': 0.014946286781877626, 'mean_word_length': 3.802690582959641, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4096032', 'n_tokens_mistral': 664, 'n_tokens_neox': 629, 'n_words': 232}