<commit_before>require 'minitest/autorun'
require 'crumbl'

class CrumblTest < Minitest::Test
  def test_decrypt_encrypted
    data = {:foo => "bar"}
    key_base = "secret key base"
    encrypted = Crumbl.encrypt(data, key_base)
    decrypted = Crumbl.decrypt(encrypted, key_base)
    assert_equal data, decrypted
  end
end<commit_msg>add tests for custom iterations<commit_after>require 'minitest/autorun'
require 'crumbl'

class CrumblTest < Minitest::Test
  def test_decrypt_encrypted
    data = {:foo => "bar"}
    key_base = "secret key base"
    encrypted = Crumbl.encrypt(data, key_base)
    decrypted = Crumbl.decrypt(encrypted, key_base)
    assert_equal data, decrypted
  end

  def test_custom_iterations_equal
    data = {:foo => "bar"}
    key_base = "secret key base"
    iterations = 1001
    encrypted = Crumbl.encrypt(data, key_base, iterations)
    decrypted = Crumbl.decrypt(encrypted, key_base, iterations)
    assert_equal data, decrypted
  end

  def test_custom_iterations_not_equal
    data = {:foo => "bar"}
    key_base = "secret key base"
    iterations = 1001
    encrypted = Crumbl.encrypt(data, key_base)
    assert_raises ActiveSupport::MessageVerifier::InvalidSignature do
      Crumbl.decrypt(encrypted, key_base, iterations)
    end
  end
end
{'fraction_non_alphanumeric': 0.09162098668754894, 'fraction_numerical': 0.006264682850430697, 'mean_word_length': 4.132530120481928, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4969210', 'n_tokens_mistral': 450, 'n_tokens_neox': 435, 'n_words': 102}