Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2016 Maximilian Pawlidi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.pawlidi.openaletheia.utils;
import java.security.Key;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Properties;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.jasypt.util.password.StrongPasswordEncryptor;
/**
*
* @author PAWLIDIM
*
*/
public final class CipherUtils {
public static final String MESSAGE_DIGEST_ALGORITHM = "MD5";
public static final String CIPHER_ALGORITHM = "RSA";
public static final String CIPHER_EXTENDED_ALGORITHM = "RSA/ECB/PKCS1Padding";
public static final String RANDOM_NUMBER_GENERATOR_ALGORITHM = "SHA1PRNG";
/** Invisible default constructor */
private CipherUtils() {
super();
}
/**
*
* @param properties
* @return
*/
public static String computeSignatureString(Properties properties) {
byte[] signature = computeSignature(properties);
return Converter.toString(signature);
}
/**
*
* @param properties
* @return
*/
public static byte[] computeSignature(Properties properties) {
if (properties != null && !properties.isEmpty()) {
StringBuilder builder = new StringBuilder();
ArrayList keys = new ArrayList