<commit_before>/**
 * Copyright (c) 2008 Sonatype, Inc. All rights reserved.
 *
 * This program is licensed to you under the Apache License Version 2.0,
 * and you may not use this file except in compliance with the Apache License Version 2.0.
 * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the Apache License Version 2.0 is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
 */
 
package org.sonatype.plexus.components.cipher;

import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.spec.KeySpec;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;

import org.codehaus.plexus.logging.AbstractLogEnabled;

/**
 * @plexus.component
 * @author <NAME></a>
 */
public class DefaultPlexusCipher
extends AbstractLogEnabled
implements PlexusCipher
{
    private static final int SALT_SIZE = 8;

    private static final String STRING_ENCODING = "UTF8";

    private PBECipher _cipher;
    
    // ---------------------------------------------------------------
    public DefaultPlexusCipher()
    throws PlexusCipherException
    {
        _cipher = new PBECipher();
    }
    // ---------------------------------------------------------------
    public String encrypt( String str, String passPhrase )
    throws PlexusCipherException
    {
        if ( str == null || str.length() < 1 )
            return str;

        return _cipher.encrypt64( str, passPhrase );
    }

    // ---------------------------------------------------------------
    public String encryptAndDecorate( String str, String passPhrase )
        throws PlexusCipherException
    {
        return decorate( encrypt( str, passPhrase ) );
    }<commit_msg>[SPICE-8] - added passphrase variable length test<commit_after>/**
 * Copyright (c) 2008 Sonatype, Inc. All rights reserved.
 *
 * This program is licensed to you under the Apache License Version 2.0,
 * and you may not use this file except in compliance with the Apache License Version 2.0.
 * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the Apache License Version 2.0 is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
 */
 
package org.sonatype.plexus.components.cipher;

import java.security.Provider;
import java.security.Security;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import org.codehaus.plexus.logging.AbstractLogEnabled;

/**
 * @plexus.component
 * @author <NAME></a>
 */
public class DefaultPlexusCipher
extends AbstractLogEnabled
implements PlexusCipher
{
    private PBECipher _cipher;
    
    // ---------------------------------------------------------------
    public DefaultPlexusCipher()
    throws PlexusCipherException
    {
        _cipher = new PBECipher();
    }
    // ---------------------------------------------------------------
    public String encrypt( String str, String passPhrase )
    throws PlexusCipherException
    {
        if ( str == null || str.length() < 1 )
            return str;

        return _cipher.encrypt64( str, passPhrase );
    }

    // ---------------------------------------------------------------
    public String encryptAndDecorate( String str, String passPhrase )
        throws PlexusCipherException
    {
        return decorate( encrypt( str, passPhrase ) );
    }
{'fraction_non_alphanumeric': 0.16324120009449564, 'fraction_numerical': 0.009685802031656036, 'mean_word_length': 2.389911929543635, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '2656272', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1069, 'n_words': 377}