📄 decrypt.h
字号:
#pragma once
#include "AES.h"
#ifndef KEY_LEN //密钥长度
#define KEY_LEN 128
#endif
#ifndef SEC_LEN //实际段长
#define SEC_LEN 64*1024
#endif
#ifndef DEC_SEC_LEN //加密后的段长
#define DEC_SEC_LEN SEC_LEN+16
#endif
#ifndef IV_LEN //初始化向量长度
#define IV_LEN 16
#endif
/**
* 第一次AES解密,调用时先用密钥和初始化向量初始化;
* 由于是严格按AES分段加密的,所以必须每次传入一段大小的缓冲区(除最后一段),用户快进或者后退
* 流媒体时,如果处在两个段之间,必须先对所在的整个段进行解密,然后才进行相应的偏移进行第二次
* 解扰处理,否则AES解密无法恢复原数据。
*/
class Decrypt
{
public:
Decrypt(unsigned char *key, unsigned char *IV,int keyLen);
int DecryptBuffer(unsigned char *buffer, unsigned char *rebuf,int len);
static unsigned long getProperPosition(int sectionLength,unsigned long streamPosition,int headerLen);
static int getBlock(int sectionLength, unsigned long streamPosition, int headerLen);
static int getSection(int sectionLength,unsigned long streamPosition, int headerLen);
~Decrypt(void);
private:
aes_context aesCtx;
unsigned char *key;
unsigned char *IV;
unsigned char tmpIV[IV_LEN];
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -