<commit_before>package edu.oregonstate.mist

import java.security.MessageDigest

class User {

    static constraints = {
    }

    static hasMany = [tasks: Task]

    private String userName
    String email
    private String passwordHash

    public User(String name, String email, String password) {
        userName = name
        this.email = email
        passwordHash = hash(password)
    }

    public String getName() { // private userName can only be accessed, not modified
        return userName
    }

    public void setPassword(String password) {
        passwordHash = hash(password)
    }

    public Boolean passwordEquals(String password) {
        return hash(password) == passwordHash
    }

    public static String sha256sum(String message) {
        MessageDigest md = MessageDigest.getInstance("SHA-256")
        md.update(message.getBytes())

        final int HEX_RADIX = 16
        byte[]     digestByteArray = md.digest()
        BigInteger digestBigInteger = new BigInteger(1, digestByteArray)
        String     digestString = digestBigInteger.toString(HEX_RADIX)

        final int SHA256SUM_LENGTH = 64
        for (int padding = SHA256SUM_LENGTH - digestString.length(); padding > 0; --padding) {
            digestString = "0" + digestString // prepend leading zeros to checksum
        }

        return digestString
    }

    private static String hash(String clearText) {
        return sha256sum(clearText)
    }
}<commit_msg>format string with method instead of loop<commit_after>package edu.oregonstate.mist

import java.security.MessageDigest

class User {

    static constraints = {
    }

    static hasMany = [tasks: Task]

    private String userName
    String email
    private String passwordHash

    public User(String name, String email, String password) {
        userName = name
        this.email = email
        passwordHash = hash(password)
    }

    public String getName() { // private userName can only be accessed, not modified
        return userName
    }

    public void setPassword(String password) {
        passwordHash = hash(password)
    }

    public Boolean passwordEquals(String password) {
        return hash(password) == passwordHash
    }

    public static String sha256sum(String message) {
        MessageDigest md = MessageDigest.getInstance("SHA-256")
        md.update(message.getBytes())

        final int HEX_RADIX = 16
        byte[]     digestByteArray = md.digest()
        BigInteger digestBigInteger = new BigInteger(1, digestByteArray)
        String     digestString = digestBigInteger.toString(HEX_RADIX)

        final int SHA256SUM_LENGTH = 64
        digestString = String.format("%"+SHA256SUM_LENGTH+"s", digestString).replace(' ', '0') // prepend leading zeros

        return digestString
    }

    private static String hash(String clearText) {
        return sha256sum(clearText)
    }
}
{'fraction_non_alphanumeric': 0.07596685082872928, 'fraction_numerical': 0.014848066298342542, 'mean_word_length': 2.6624525916561317, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1079919', 'n_tokens_mistral': 814, 'n_tokens_neox': 745, 'n_words': 221}