Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

public class Main {
    private static final String key = "homelane_crypt_k";

    /**
     * function decrypt the string and return the result
     * @param stringToDecrypt the string against which the decryption to be performed
     * @return the decrypted String
     */
    public static final String decrypt(String stringToDecrypt) {
        try {
            Key aesKey = new SecretKeySpec(key.getBytes(), "AES");
            Cipher cipher = Cipher.getInstance("AES");
            cipher.init(Cipher.DECRYPT_MODE, aesKey);
            return new String(cipher.doFinal(stringToDecrypt.getBytes()));
        } catch (Exception e) {

        }
        return null;
    }
}