<commit_before>
from Crypto.Cipher import AES
import random, struct, hashlib, os

def keygen(password):
	return hashlib.sha256(password).digest()

def encrypt(key, file_name, chunksize = 64 * 1024):
	# Encrypts the file
	output = file_name + '.enc'
	
	IV = ''.join(chr(random.randint(0, 0xFF)) for i in range(16))
	encryptor = AES.new(key, AES.MODE_CBC, IV)
	file_size = os.path.getsize(file_name)

	with open(file_name, 'rb') as infile:
		with open(output, 'wb') as outfile:
			outfile.write(struct.pack('<Q', file_size))
			outfile.write(IV)

			while True:
				chunk = infile.read(chunksize)
				if len(chunk) == 0:
					break
				elif len(chunk) % 16 != 0:
					chunk += ' ' * (16 - len(chunk) % 16)

				outfile.write(encryptor.encrypt(chunk))


def decrypt(key, file_name, chunksize = 24 * 1024):
	# Decrypts the file<commit_msg>Change encrypted file extension from .enc to .crib<commit_after>
from Crypto.Cipher import AES
import random, struct, hashlib, os

def keygen(password):
	return hashlib.sha256(password).digest()

def encrypt(key, file_name, chunksize = 64 * 1024):
	# Encrypts the file
	output = file_name + '.crib'
	
	IV = ''.join(chr(random.randint(0, 0xFF)) for i in range(16))
	encryptor = AES.new(key, AES.MODE_CBC, IV)
	file_size = os.path.getsize(file_name)

	with open(file_name, 'rb') as infile:
		with open(output, 'wb') as outfile:
			outfile.write(struct.pack('<Q', file_size))
			outfile.write(IV)

			while True:
				chunk = infile.read(chunksize)
				if len(chunk) == 0:
					break
				elif len(chunk) % 16 != 0:
					chunk += ' ' * (16 - len(chunk) % 16)

				outfile.write(encryptor.encrypt(chunk))


def decrypt(key, file_name, chunksize = 24 * 1024):
	# Decrypts the file
{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.03161592505854801, 'mean_word_length': 3.910919540229885, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1141085', 'n_tokens_mistral': 751, 'n_tokens_neox': 625, 'n_words': 162}