// Path: src/main/java/com/mpush/api/connection/Cipher.java
// public interface Cipher {
// 
//     byte[] decrypt(byte[] data);
// 
//     byte[] encrypt(byte[] data);
// 
// }
// 
// Path: src/main/java/com/mpush/util/crypto/AESUtils.java
// public final class AESUtils {
//     public static final String KEY_ALGORITHM = "AES";
//     public static final String KEY_ALGORITHM_PADDING = "AES/CBC/PKCS5Padding";
// 
// 
//     public static byte[] encrypt(byte[] data, byte[] encryptKey, byte[] iv) {
//         IvParameterSpec zeroIv = new IvParameterSpec(iv);
//         SecretKeySpec key = new SecretKeySpec(encryptKey, KEY_ALGORITHM);
//         try {
//             Cipher cipher = Cipher.getInstance(KEY_ALGORITHM_PADDING);
//             cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv);
//             return cipher.doFinal(data);
//         } catch (Exception e) {
//             ClientConfig.I.getLogger().e(e, "encrypt ex, decryptKey=%s", encryptKey);
//         }
//         return Constants.EMPTY_BYTES;
//     }
// 
//     public static byte[] decrypt(byte[] data, byte[] decryptKey, byte[] iv) {
//         IvParameterSpec zeroIv = new IvParameterSpec(iv);
//         SecretKeySpec key = new SecretKeySpec(decryptKey, KEY_ALGORITHM);
//         try {
//             Cipher cipher = Cipher.getInstance(KEY_ALGORITHM_PADDING);
//             cipher.init(Cipher.DECRYPT_MODE, key, zeroIv);
//             return cipher.doFinal(data);
//         } catch (Exception e) {
//             ClientConfig.I.getLogger().e(e, "decrypt ex, decryptKey=%s", decryptKey);
//         }
//         return Constants.EMPTY_BYTES;
//     }
// }


import com.mpush.util.crypto.AESUtils;
import com.mpush.api.connection.Cipher;
/*
 * (C) Copyright 2015-2016 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
 *
 * 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.
 *
 * Contributors:
 *     ohun@live.cn (夜色)
 */

package com.mpush.security;




/**
 * Created by ohun on 2015/12/28.
 *
 * @author ohun@live.cn (夜色)
 */
public final class AesCipher implements Cipher {
    public final byte[] key;
    public final byte[] iv;

    public AesCipher(byte[] key, byte[] iv) {
        this.key = key;
        this.iv = iv;
    }

    @Override
    public byte[] decrypt(byte[] data) {
// Path: src/main/java/com/mpush/api/connection/Cipher.java
// public interface Cipher {
// 
//     byte[] decrypt(byte[] data);
// 
//     byte[] encrypt(byte[] data);
// 
// }
// 
// Path: src/main/java/com/mpush/util/crypto/AESUtils.java
// public final class AESUtils {
//     public static final String KEY_ALGORITHM = "AES";
//     public static final String KEY_ALGORITHM_PADDING = "AES/CBC/PKCS5Padding";
// 
// 
//     public static byte[] encrypt(byte[] data, byte[] encryptKey, byte[] iv) {
//         IvParameterSpec zeroIv = new IvParameterSpec(iv);
//         SecretKeySpec key = new SecretKeySpec(encryptKey, KEY_ALGORITHM);
//         try {
//             Cipher cipher = Cipher.getInstance(KEY_ALGORITHM_PADDING);
//             cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv);
//             return cipher.doFinal(data);
//         } catch (Exception e) {
//             ClientConfig.I.getLogger().e(e, "encrypt ex, decryptKey=%s", encryptKey);
//         }
//         return Constants.EMPTY_BYTES;
//     }
// 
//     public static byte[] decrypt(byte[] data, byte[] decryptKey, byte[] iv) {
//         IvParameterSpec zeroIv = new IvParameterSpec(iv);
//         SecretKeySpec key = new SecretKeySpec(decryptKey, KEY_ALGORITHM);
//         try {
//             Cipher cipher = Cipher.getInstance(KEY_ALGORITHM_PADDING);
//             cipher.init(Cipher.DECRYPT_MODE, key, zeroIv);
//             return cipher.doFinal(data);
//         } catch (Exception e) {
//             ClientConfig.I.getLogger().e(e, "decrypt ex, decryptKey=%s", decryptKey);
//         }
//         return Constants.EMPTY_BYTES;
//     }
// }


// Path: src/main/java/com/mpush/security/AesCipher.java
import com.mpush.util.crypto.AESUtils;
import com.mpush.api.connection.Cipher;

/*
 * (C) Copyright 2015-2016 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
 *
 * 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.
 *
 * Contributors:
 *     ohun@live.cn (夜色)
 */

package com.mpush.security;




/**
 * Created by ohun on 2015/12/28.
 *
 * @author ohun@live.cn (夜色)
 */
public final class AesCipher implements Cipher {
    public final byte[] key;
    public final byte[] iv;

    public AesCipher(byte[] key, byte[] iv) {
        this.key = key;
        this.iv = iv;
    }

    @Override
    public byte[] decrypt(byte[] data) {
        return AESUtils.decrypt(data, key, iv);