admin
2021-01-04 aa6ef62aef83e277d4171df1d9f0803f91738216
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.newvideo.util.video;
 
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
 
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
 
import com.newvideo.util.StringUtil;
 
public class YouKuAesUtils {
    public static String decrypt(String paramString) throws UnsupportedEncodingException {
        return new String(decrypt(StringUtil.getFromBase64Byte(paramString),
                "qwer3as2jin4fdsa"));
    }
 
    public static byte[] decrypt(byte[] paramArrayOfByte, String paramString) {
        try {
            KeyGenerator localKeyGenerator = KeyGenerator.getInstance("AES");
            byte[] arrayOfByte1 = paramString.getBytes();
            SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
            secureRandom.setSeed(paramString.getBytes());
            localKeyGenerator.init(secureRandom);
            SecretKeySpec localSecretKeySpec = new SecretKeySpec(arrayOfByte1,
                    "AES");
            Cipher localCipher = Cipher.getInstance("AES/ECB/NoPadding");
            localCipher.init(2, localSecretKeySpec);
            byte[] arrayOfByte2 = localCipher.doFinal(paramArrayOfByte);
            return arrayOfByte2;
        } catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {
            localNoSuchAlgorithmException.printStackTrace();
            return null;
        } catch (NoSuchPaddingException localNoSuchPaddingException) {
            localNoSuchPaddingException.printStackTrace();
        } catch (InvalidKeyException localInvalidKeyException) {
            localInvalidKeyException.printStackTrace();
        } catch (IllegalBlockSizeException localIllegalBlockSizeException) {
            localIllegalBlockSizeException.printStackTrace();
        } catch (BadPaddingException localBadPaddingException) {
            localBadPaddingException.printStackTrace();
        }
        return null;
    }
}