com.baidubce.services.iothisk.device.crypto
Class AesEncrypt

java.lang.Object
  extended by com.baidubce.services.iothisk.device.crypto.AesEncrypt

public class AesEncrypt
extends Object

Provides AES crypto functions


Constructor Summary
AesEncrypt()
           
 
Method Summary
static byte[] decrypt(byte[] data, SecretKey key, IvParameterSpec iv, String cipherName)
          Decrypt message with specified secret key, cipher name, init vector and cipher name.
static byte[] decryptByCTRNoPadding(byte[] data, byte[] key, byte[] iv)
          Decrypt message with AES/CTR/NoPadding cipher
static byte[] encrypt(byte[] data, SecretKey key, IvParameterSpec iv, String cipherName)
          Encrypt message with specified secret key, cipher name, init vector and cipher name.
static byte[] encrypt(byte[] data, SecretKey key, String cipherName)
          Encrypt message with specified secret key and cipher name.
static byte[] encryptByCTRNoPadding(byte[] data, byte[] key, byte[] iv)
          Encrypt message with AES/CTR/NoPadding cipher
static SecretKey loadKey(byte[] key, String algorithm)
          Load secret key with provided key data and specified algorithm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AesEncrypt

public AesEncrypt()
Method Detail

loadKey

public static SecretKey loadKey(byte[] key,
                                String algorithm)
Load secret key with provided key data and specified algorithm

Parameters:
key - specified key data in btye array
algorithm - specified algorithm
Returns:
secret key

encrypt

public static byte[] encrypt(byte[] data,
                             SecretKey key,
                             String cipherName)
Encrypt message with specified secret key and cipher name.

Parameters:
data - specified message data in byte array
key - specified secret key
cipherName - specified cipher name
Returns:
cipher message in byte array

encrypt

public static byte[] encrypt(byte[] data,
                             SecretKey key,
                             IvParameterSpec iv,
                             String cipherName)
Encrypt message with specified secret key, cipher name, init vector and cipher name.

Parameters:
data - specified message data in byte array
key - specified secret key
iv - specified init vector
cipherName - specified cipher name
Returns:
cipher message in byte array

decrypt

public static byte[] decrypt(byte[] data,
                             SecretKey key,
                             IvParameterSpec iv,
                             String cipherName)
Decrypt message with specified secret key, cipher name, init vector and cipher name.

Parameters:
data - specified cipher message data in byte array
key - specified secret key
iv - specified init vector
cipherName - specified cipher name
Returns:
plain message in byte array

encryptByCTRNoPadding

public static byte[] encryptByCTRNoPadding(byte[] data,
                                           byte[] key,
                                           byte[] iv)
Encrypt message with AES/CTR/NoPadding cipher

Parameters:
data - specified message data in byte array
key - specified key in byte array
iv - specified init vector
Returns:
cipher message in byte array

decryptByCTRNoPadding

public static byte[] decryptByCTRNoPadding(byte[] data,
                                           byte[] key,
                                           byte[] iv)
Decrypt message with AES/CTR/NoPadding cipher

Parameters:
data - specified message data in byte array
key - specified key in byte array
iv - specified init vector
Returns:
plain message in byte array


Copyright © 2020. All rights reserved.