<commit_before>package org.bouncycastle.crypto.generators;

import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.PBEParametersGenerator;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.params.ParametersWithIV;
import org.bouncycastle.crypto.util.DigestFactory;

/**
 * Generator for PBE derived keys and ivs as usd by OpenSSL.
 * <p>
 * The scheme is a simple extension of PKCS 5 V2.0 Scheme 1 using MD5 with an
 * iteration count of 1.
 * <p>
 */
public class OpenSSLPBEParametersGenerator
    extends PBEParametersGenerator
{
    private Digest  digest = DigestFactory.createMD5();

    /**
     * Construct a OpenSSL Parameters generator. 
     */
    public OpenSSLPBEParametersGenerator()
    {
    }

    /**
     * Initialise - note the iteration count for this algorithm is fixed at 1.
     * 
     * @param password <PASSWORD>.
     * @param salt salt to use.
     */
    public void init(
       byte[] password,
       byte[] salt)
    {
        super.init(password, salt, 1);<commit_msg>added ability to set digest in line with changes to OpenSSL 1.1.0<commit_after>package org.bouncycastle.crypto.generators;

import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.PBEParametersGenerator;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.params.ParametersWithIV;
import org.bouncycastle.crypto.util.DigestFactory;

/**
 * Generator for PBE derived keys and ivs as usd by OpenSSL.
 * <p>
 * Originally this scheme was a simple extension of PKCS 5 V2.0 Scheme 1 using MD5 with an
 * iteration count of 1. The default digest was changed to SHA-256 with OpenSSL 1.1.0. This
 * implementation still defaults to MD5, but the digest can now be set.
 * <p>
 */
public class OpenSSLPBEParametersGenerator
    extends PBEParametersGenerator
{
    private final Digest  digest;

    /**
     * Construct a OpenSSL Parameters generator - digest the original MD5.
     */
    public OpenSSLPBEParametersGenerator()
    {
        this(DigestFactory.createMD5());
    }

    /**
     * Construct a OpenSSL Parameters generator - digest as specified.
     *
     * @param digest the digest to use as the PRF.
     */
    public OpenSSLPBEParametersGenerator(Digest digest)
    {
        this.digest = digest;
    }

    /**
     * Initialise - note the iteration count for this algorithm is fixed at 1.
     * 
     * @param password password to use.
     * @param salt salt to use.
     */
    public void init(
       byte[] password,
       byte[] salt)
    {
        super.init(password, salt, 1);
{'fraction_non_alphanumeric': 0.08416759362254357, 'fraction_numerical': 0.010752688172043012, 'mean_word_length': 3.0755287009063443, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '3638035', 'n_tokens_mistral': 811, 'n_tokens_neox': 786, 'n_words': 249}