You can not select more than 25 topics
Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- package Null_Password;
-
- import java.security.InvalidKeyException;
- import java.security.NoSuchAlgorithmException;
- import java.util.logging.Logger;
-
- import javax.crypto.BadPaddingException;
- import javax.crypto.Cipher;
- import javax.crypto.IllegalBlockSizeException;
- import javax.crypto.NoSuchPaddingException;
- import javax.crypto.spec.SecretKeySpec;
-
- public class Null_Password {
-
- static final Logger log = Logger.getLogger("logger");
-
- public String bad() {
-
- String password = null; // bad null密码
-
- return password;
- }
-
- public String good()
- {
- String data = "key"; /* init data */
-
- String sKey = "Skey";
- Cipher cipher = null;
- String pw = "";
- try {
- SecretKeySpec key = new SecretKeySpec(sKey.getBytes(), "AES");
- cipher = Cipher.getInstance("AES");
- cipher.init(Cipher.DECRYPT_MODE, key);
- }catch (NoSuchPaddingException e) {
- log.info("error");
- } catch (NoSuchAlgorithmException e) {
- log.info("error");
- } catch (InvalidKeyException e) {
- log.info("InvalidKeyException");
- }
-
- try {
- if(cipher != null){
- pw = new String(cipher.doFinal(data.getBytes()));
- }
-
- } catch (IllegalBlockSizeException e) {
- log.info("error");
- } catch (BadPaddingException e) {
- log.info("error");
- }
-
- String password = pw; // good null密码
-
- return password;
-
- }
-
- }
|