<commit_before>/*
 * 
 * 
 * Copyright (C) 2004 SIPfoundry Inc.
 * Licensed by SIPfoundry under the LGPL license.
 * 
 * Copyright (C) 2004 Pingtel Corp.
 * Licensed to SIPfoundry under a Contributor Agreement.
 * 
 * $$
 */

package org.sipfoundry.sipxconfig.common;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Helper method for creating passtokens
 */
public final class Md5Encoder {
    private static final Log LOG = LogFactory.getLog(Md5Encoder.class);
    
    /** MD5 message digest length */
    public static final int LEN = 32;

    private Md5Encoder() {
        // do not instantiate
    }

    /**
     * Computes the digest without DNS domain name
     */
    public static final String digestPassword(String user, String realm, String password) {
        String full = user + ':' + realm + ':' + password;
        String digest = DigestUtils.md5Hex(full);
        if (LOG.isDebugEnabled()) {
            LOG.debug(full + " -> " + digest);
        }
        return digest;
    }

    /**
     * Computes the digest with DNS domain name - "old way" left for compatibility In future we<commit_msg>checkstyle fix<commit_after>/*
 * 
 * 
 * Copyright (C) 2004 SIPfoundry Inc.
 * Licensed by SIPfoundry under the LGPL license.
 * 
 * Copyright (C) 2004 Pingtel Corp.
 * Licensed to SIPfoundry under a Contributor Agreement.
 * 
 * $$
 */

package org.sipfoundry.sipxconfig.common;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Helper method for creating passtokens
 */
public final class Md5Encoder {
    /** MD5 message digest length */
    public static final int LEN = 32;

    private static final Log LOG = LogFactory.getLog(Md5Encoder.class);
    
    private Md5Encoder() {
        // do not instantiate
    }

    /**
     * Computes the digest without DNS domain name
     */
    public static final String digestPassword(String user, String realm, String password) {
        String full = user + ':' + realm + ':' + password;
        String digest = DigestUtils.md5Hex(full);
        if (LOG.isDebugEnabled()) {
            LOG.debug(full + " -> " + digest);
        }
        return digest;
    }

    /**
     * Computes the digest with DNS domain name - "old way" left for compatibility In future we
{'fraction_non_alphanumeric': 0.1040033016921172, 'fraction_numerical': 0.012381345439537762, 'mean_word_length': 2.672727272727273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4442976', 'n_tokens_mistral': 749, 'n_tokens_neox': 698, 'n_words': 218}