com.github.javaclub.toolbox.crypt.MiscCryptor Maven / Gradle / Ivy
/*
* @(#)MiscCryptor.java 2021-3-31
*
* Copyright (c) 2021. All Rights Reserved.
*
*/
package com.github.javaclub.toolbox.crypt;
/**
* 可逆的混淆加密算法
*
* @author Gerald Chen
* @version $Id: MiscCryptor.java 2021-3-31 16:40:14 Exp $
*/
public class MiscCryptor {
public static void main(String[] args) {
String pwd = "6dbe1a64a783911b344f89d203b3ad31";
// W7cW+75Jv6Hyh+/n0pJLXPbtGyxLQUTUHtlzXK5oxqagX7HO+8qieN==
// W7cW+75Jv6Hyh+/n0pJLXPbtGyxLQUTUHtlzXK5oxqagX7HO+8qieN==
String encrypt = encrypt(pwd);
System.out.println("encryptedText = " + encrypt);
String decrypt = decrypt(encrypt);
System.out.println("originalText = " + decrypt);
}
public static String encrypt(String plainText) {
String encode = Blowfish.encrypt(plainText);
return SimpleEncryptor.encrypt(encode);
}
public static String decrypt(String encryptedText) {
String decode = SimpleEncryptor.decrypt(encryptedText);
return Blowfish.decrypt(decode);
}
public static String encrypt(String plainText, String secret) {
String encode = Blowfish.encrypt(plainText, secret);
return SimpleEncryptor.encrypt(encode);
}
public static String decrypt(String encryptedText, String secret) {
String decode = SimpleEncryptor.decrypt(encryptedText);
return Blowfish.decrypt(decode, secret);
}
}