<commit_before><commit_msg>[java] add a simple test for symmetric encryption<commit_after>package selectvoting.tests;

import junit.framework.TestCase;

import org.junit.Test;

import selectvoting.lib.crypto.CryptoLib;
import selectvoting.utils.Utilities;
import static selectvoting.utils.MessageTools.equal;


public class TestCryptoLib extends TestCase {

	private static byte[] key = Utilities.hexStringToByteArray("<KEY>");
	private static byte[] encrypted_message = Utilities.hexStringToByteArray("1693e24f26f49c096e7cf5e73800d5ded1aac5bbfc3ee9dc586a1244a2ce5a");
	private static byte[] encrypted_plaintext = Utilities.hexStringToByteArray("3f2267");


	private void log(byte[] b) {
		System.out.println(Utilities.byteArrayToHexString(b));
	}

	@Test
	public void testSymEnc() {
		byte[] plaintext = {0x3f,0x22};

		byte[] c = CryptoLib.symkey_encrypt(key, plaintext);	
		byte[] m = CryptoLib.symkey_decrypt(key, c);
		log(m);
		assertTrue( equal(plaintext,m) );

		byte[] m1 = CryptoLib.symkey_decrypt(key, encrypted_message);
		assertTrue( equal(m1, encrypted_plaintext));
		log(m1);
	}
}
{'fraction_non_alphanumeric': 0.11506849315068493, 'fraction_numerical': 0.042922374429223746, 'mean_word_length': 6.558620689655172, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '7379720', 'n_tokens_mistral': 414, 'n_tokens_neox': 381, 'n_words': 71}