<commit_before>package fr.utc.assos.uvweb.util;

import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class GravatarUtils {
	private static final int IMAGE_QUALITY_MIN_THRESHOLD = 50;
	private static final String BASE_GRAVATAR_URL = "http://www.gravatar.com/avatar/";
	private static final StringBuilder sStringBuilder = new StringBuilder();

	public static String convertEmailToHash(String email) {
		final MessageDigest messageDigest;
		try {
			messageDigest = MessageDigest.getInstance("MD5");
			messageDigest.reset();
			messageDigest.update(email.getBytes(Charset.forName("UTF8")));
			final byte[] resultBytes = messageDigest.digest();
			final StringBuilder sb = new StringBuilder();
			for (byte resultByte : resultBytes) {
				sb.append(Integer.toHexString((resultByte & 0xFF) | 0x100).substring(1, 3));
			}
			return sb.toString();
		} catch (NoSuchAlgorithmException e) {
			return email;
		}
	}

	public static String computeUrlRequest(String hash, final int requestedSize) {
		sStringBuilder.setLength(0);
		sStringBuilder.append(BASE_GRAVATAR_URL);<commit_msg>Reuse the StringBuilder interface in the hash computation as well<commit_after>package fr.utc.assos.uvweb.util;

import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class GravatarUtils {
	private static final int IMAGE_QUALITY_MIN_THRESHOLD = 50;
	private static final String BASE_GRAVATAR_URL = "http://www.gravatar.com/avatar/";
	private static final StringBuilder sStringBuilder = new StringBuilder();

	public static String convertEmailToHash(String email) {
		final MessageDigest messageDigest;
		try {
			messageDigest = MessageDigest.getInstance("MD5");
			messageDigest.reset();
			messageDigest.update(email.getBytes(Charset.forName("UTF8")));
			final byte[] resultBytes = messageDigest.digest();
			sStringBuilder.setLength(0);
			for (byte resultByte : resultBytes) {
				sStringBuilder.append(Integer.toHexString((resultByte & 0xFF) | 0x100).substring(1, 3));
			}
			return sStringBuilder.toString();
		} catch (NoSuchAlgorithmException e) {
			return email;
		}
	}

	public static String computeUrlRequest(String hash, final int requestedSize) {
		sStringBuilder.setLength(0);
		sStringBuilder.append(BASE_GRAVATAR_URL);
{'fraction_non_alphanumeric': 0.10021231422505308, 'fraction_numerical': 0.010615711252653927, 'mean_word_length': 5.544444444444444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6880277', 'n_tokens_mistral': 787, 'n_tokens_neox': 708, 'n_words': 158}