All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.sbb.releasetrain.utils.crypt.EncryptorImpl Maven / Gradle / Ivy

There is a newer version: 0.9.6
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements;
 * and to You under the Apache License, Version 2.0.
 */
package ch.sbb.releasetrain.utils.crypt;

import lombok.extern.slf4j.Slf4j;
import org.jasypt.util.text.BasicTextEncryptor;

/**
 * http://www.jasypt.org/easy-usage.html
 */
@Slf4j
public class EncryptorImpl {

	private static final String MY_ENCRIPTED_PASSWORD = "* http://www.jasypt.org/easy-usage.html";

	public static String decrypt(final String encryptedVal) {
		if (encryptedVal == null) {
			return null;
		}
		BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
		textEncryptor.setPassword(MY_ENCRIPTED_PASSWORD);
		return textEncryptor.decrypt(encryptedVal);

	}

	public static String encrypt(final String valueEnc) {
		if (valueEnc == null) {
			return null;
		}
		BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
		textEncryptor.setPassword(MY_ENCRIPTED_PASSWORD);
		return textEncryptor.encrypt(valueEnc);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy