Java tutorial
//package com.java2s; /* * Copyright (C) 2011 The Code Bakers * Authors: Cleuton Sampaio e Francisco Rodrigues * e-mail: thecodebakers@gmail.com * Project: http://code.google.com/p/hercules-password-protector * Site: http://thecodebakers.blogspot.com * * Licensed under the GNU GPL, Version 3.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://gplv3.fsf.org/ * * 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. * * @author Cleuton Sampaio e Francisco Rogrigues - thecodebakers@gmail.com */ import java.security.InvalidKeyException; import java.security.Key; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; public class Main { private static Key key = null; private static Cipher cipher = null; public static String decrypt(byte[] encryptionBytes) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException { cipher.init(Cipher.DECRYPT_MODE, key); byte[] recoveredBytes = cipher.doFinal(encryptionBytes); String recovered = new String(recoveredBytes); return recovered; } }