<commit_before><?php
$KEY_SIZE = 16;
$ENCRYPTION_KEY = 'thisisasamplepassphraseforencoding';

// PKCS#5 Padding
function pad_pkcs5($text) {
  try {
    $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
    $pad = $size - (strlen($text) % $size);
    return $text . str_repeat(chr($pad), $pad);
  } catch (Exception $e) {
    echo "Padding exception in pad_pkcs5(): " . $e->getMessage() . "\n";
  }
}

function unpad_pkcs5($text) {
  try {
		$pad_chr = substr($text, -1);
		$pad = ord($pad_chr);

		// Check padding
		if (strspn($text, $pad_chr, strlen($text) - $pad) != $pad) 
      throw new Exception('Invalid padding');
		return substr($text, 0, -1 * $pad);
  } catch (Exception $e) {
    echo "Padding exception in unpad_pkcs5(): " . $e->getMessage() . "\n";
  }
}

// Encryption using AES CBC (128-bits)
function encrypt($plaintext, $passphrase, $iv) {
  try {<commit_msg>Update encryption_demo.php<commit_after><?php
$KEY_SIZE = 16;
$ENCRYPTION_KEY = 'thisisasamplepassphraseforencoding';

// PKCS#5 Padding
function pad_pkcs5($text) {
  try {
    $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
    $pad = $size - (strlen($text) % $size);
    return $text . str_repeat(chr($pad), $pad);
  } catch (Exception $e) {
    echo "Padding exception in pad_pkcs5(): " . $e->getMessage() . "\n";
  }
}

function unpad_pkcs5($text) {
  try {
    $pad_chr = substr($text, -1);
    $pad = ord($pad_chr);

	// Check padding
    if (strspn($text, $pad_chr, strlen($text) - $pad) != $pad) 
      throw new Exception('Invalid padding');
		return substr($text, 0, -1 * $pad);
  } catch (Exception $e) {
    echo "Padding exception in unpad_pkcs5(): " . $e->getMessage() . "\n";
  }
}

// Encryption using AES CBC (128-bits)
function encrypt($plaintext, $passphrase, $iv) {
  try {
{'fraction_non_alphanumeric': 0.17734806629834254, 'fraction_numerical': 0.017679558011049725, 'mean_word_length': 3.791005291005291, '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': '5288569', 'n_tokens_mistral': 722, 'n_tokens_neox': 683, 'n_words': 153}