import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
* data数据加解密 Constants.UNKNOWN=0xFF
public class DataJiaJieMi {
/* renamed from: a */
public static byte[] m15639a(byte[] bArr, byte[] bArr2) {
byte[] bArr3 = new byte[(bArr.length + bArr2.length)];
System.arraycopy(bArr, 0, bArr3, 0, bArr.length);
System.arraycopy(bArr2, 0, bArr3, bArr.length, bArr2.length);
return bArr3;
* Data加密
* @param str 密钥
* @param str2 要加密的数据
* @return
/* renamed from: b */
public static String m15641b(String str, String str2) {
try {
Cipher instance = Cipher.getInstance("AES/CFB/NoPadding");
byte[][] a = m15640a(32, 16, null, str.getBytes("UTF-8"), 0);
instance.init(1, new SecretKeySpec(a[0], "AES"), new IvParameterSpec(a[1]));
return m15642b(m15639a(instance.getIV(), instance.doFinal(str2.getBytes("UTF-8"))));
} catch (Exception e) {
e.printStackTrace();
return null;
* Data解密
* @param str 密钥
* @param str2 要解密的数据
* @return
/* renamed from: a */
public static String m15637a(String str, String str2) {
try {
byte[] b = m15643b(str2);
byte[] copyOfRange = Arrays.copyOfRange(b, 0, 16);
byte[] copyOfRange2 = Arrays.copyOfRange(b, 16, b.length);
byte[][] a = m15640a(32, 16, null, str.getBytes("UTF-8"), 0);
IvParameterSpec ivParameterSpec = new IvParameterSpec(copyOfRange);
SecretKeySpec secretKeySpec = new SecretKeySpec(a[0], "AES");
Cipher instance = Cipher.getInstance("AES/CFB/NoPadding");
instance.init(2, secretKeySpec, ivParameterSpec);
return new String(instance.doFinal(copyOfRange2), "UTF-8");
} catch (Exception e) {
e.printStackTrace();
return null;
/* renamed from: b */
public static byte[] m15643b(String str) {
if (str == null) {
return null;
int length = str.length();
if (length % 2 == 1) {
return null;
int i = length / 2;
byte[] bArr = new byte[i];
for (int i2 = 0; i2 != i; i2++) {
int i3 = i2 * 2;
bArr[i2] = (byte) Integer.parseInt(str.substring(i3, i3 + 2), 16);
return bArr;
/* renamed from: b */
public static String m15642b(byte[] bArr) {
String str = "";
for (byte b : bArr) {
String hexString = Integer.toHexString(b & 0xFF);
str = hexString.length() == 1 ? str + "0" + hexString : str + hexString;
return str.toUpperCase();
/* renamed from: a */
public static byte[][] m15640a(int i, int i2, byte[] bArr, byte[] bArr2, int i3) throws Exception {
byte[] digest;
MessageDigest instance = MessageDigest.getInstance("md5");
byte[] bArr3 = new byte[i];
byte[] bArr4 = new byte[i2];
byte[][] bArr5 = {bArr3, bArr4};
if (bArr2 == null) {
return bArr5;
byte[] bArr6 = null;
int i4 = i2;
int i5 = 0;
int i6 = 0;
int i7 = i;
int i8 = 0;
while (true) {
instance.reset();
int i9 = i8 + 1;
if (i8 > 0) {
instance.update(bArr6);
instance.update(bArr2);
if (bArr != null) {
instance.update(bArr, 0, 8);
digest = instance.digest();
for (int i10 = 1; i10 < i3; i10++) {
instance.reset();
instance.update(digest);
digest = instance.digest();
int i11 = 0;
if (i7 > 0) {
while (i7 != 0 && i11 != digest.length) {
bArr3[i5] = digest[i11];
i7--;
i11++;
i5++;
if (i4 > 0 && i11 != digest.length) {
while (i4 != 0 && i11 != digest.length) {
bArr4[i6] = digest[i11];
i4--;
i11++;
i6++;
if (i7 == 0 && i4 == 0) {
break;
i8 = i9;
bArr6 = digest;
for (int i12 = 0; i12 < digest.length; i12++) {
digest[i12] = 0;
return bArr5;
* MD5
* @param str MD5的数据
* @return
/* renamed from: a */
public static String m15636a(String str) {
try {
MessageDigest instance = MessageDigest.getInstance("SHA-256");
instance.update(str.getBytes("UTF-8"));
return m15638a(instance.digest());
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e2) {
e2.printStackTrace();
return "";
/* renamed from: a */
public static String m15638a(byte[] bArr) {
StringBuffer stringBuffer = new StringBuffer();
for (byte b : bArr) {
String hexString = Integer.toHexString(b & 0xFF);
if (hexString.length() == 1) {
stringBuffer.append("0");
stringBuffer.append(hexString);
return stringBuffer.toString();
import java.io.UnsupportedEncodingException;import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;import java.util.Arrays;import javax.crypto.Cipher;import javax.crypto.spec.IvParameterSpec;import javax.crypto.spec.Secre..
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.tomcat.util.codec.binary.Base64;
import
java
x.crypto.Cipher;
import
java
x.crypto.spec.IvParameterSpec;
import
java
x.crypto.spec.SecretKeySpec;
* AEC加密工具类
public class
Aes
Util .
import
java
.io.IOException;
import
java
.io.RandomAccessFile;
import
java
.nio.ByteBuffer;
import j.
key = 'keyxxx'.encode()
mode =
AES
.MODE_
CFB
cryptos =
AES
.new(key, mode, 'ivxxxx'.encode(),segment_size=128)
cipher_text = cryptos.encrypt(text.encode())
AES
-128-
CFB
是一种高级加密标准。他是一种分组加密算法,可用于互联网上的加密通信和数据保护。该算法的输入和输出都是以128位块为单位,而且是对称加密算法,这意味着加密和解密都使用相同的密钥。而
CFB
模式是一种分组模式,它可以使用更小的块加密,将明文分为连续的块,之后加上密钥通过一系列的变换实现加密。 对于C语言的实现来说,可以使用开源的加密库OpenSSL来实现
AES
-128-
CFB
加密算法。在C代码中使用OpenSSL库来实现加密,可以通过以下步骤实现:
1.在系统中安装OpenSSL库。
2.在C代码中包含OpenSSL库中的头文件。
3.使用OpenSSL库中的函数进行
AES
-128-
CFB
加密和解密操作。
例如,要在C语言中使用
AES
-128-
CFB
加密算法加密数据,我们可以使用OpenSSL库提供的接口函数进行加密操作。
AES
_set_encrypt_key(秘钥,128,&key);
AES
_
cfb
128_encrypt(要加密的数据,加密后的数据,要加密的数据的长度,&key,iv,&num,
AES
_ENCRYPT);
其中秘钥为要使用的密钥,iv 为随机初始化向量,num 为加密或解密的数据块大小。在这个例子中,加密操作使用
AES
_
cfb
128_encrypt() 函数进行实现,加密后的结果存放在加密后的数据参数指针中。
总之,
AES
-128-
CFB
是一种安全可靠的加密算法,能够很好地保护数据的安全性。在C语言中,可以使用OpenSSL库来实现此算法。