xlang v5.1 Release
程序设计语言基础库文档
载入中...
搜索中...
未找到
Cipher类 参考

提供加密和解密操作的抽象类,支持多种加密算法和模式。 更多...

Cipher 的协作图:
Collaboration graph

Public 成员函数

静态 Public 成员函数

详细描述

提供加密和解密操作的抽象类,支持多种加密算法和模式。

在文件 Cipher.x5 行定义.

成员函数说明

◆ doFinal()

byte [] doFinal ( byte []  input,
int  offset,
int  length 
)

完成加密或解密操作,处理剩余数据。

参数
input输入字节数组。
offset输入数据的起始偏移量。
length输入数据的长度。
返回
处理后的字节数组,不能为空指针。
异常
std::out_of_range如果偏移量或长度超出范围。

◆ finalize()

void finalize ( )

释放Cipher对象相关资源。

◆ getAlgorithm()

String getAlgorithm ( )

获取当前Cipher对象使用的算法名称。

返回
算法名称字符串,不能为空指针。

◆ getBlockSize()

int getBlockSize ( )

获取加密算法的块大小(字节数)。

返回
块大小。

◆ getInstance()

static final Cipher getInstance ( String  algorithm)
static

获取指定算法的Cipher实例(单例)。

参数
algorithm加密算法名称。
返回
Cipher对象,不能为空指针。
异常
std::invalid_argument如果算法名称无效。

◆ getIV()

byte [] getIV ( )

获取当前Cipher对象的初始化向量(IV)。

返回
IV字节数组,不能为空指针。

◆ getOutputSize()

int getOutputSize ( int  inputLen)

获取指定输入长度对应的输出长度。

参数
inputLen输入数据长度。
返回
输出数据长度。

◆ getSupportAlgorithms()

static final String getSupportAlgorithms ( )
static

获取当前支持的所有加密算法名称列表。

返回
支持算法名称字符串,不能为空指针。

◆ init()

bool init ( int  mode,
Key  key,
Object  params 
)

初始化Cipher对象。

参数
mode操作模式(如ENCRYPT_MODE、DECRYPT_MODE等)。
key密钥对象。
params算法参数对象,可选。
返回
初始化是否成功。
异常
std::invalid_argument如果参数无效。

◆ newInstance()

Cipher newInstance ( String  algorithm)

创建指定算法的Cipher实例。

参数
algorithm加密算法名称。
返回
新创建的Cipher对象,不能为空指针。
异常
std::invalid_argument如果算法名称无效。

◆ registryCipher()

static final bool registryCipher ( String  algorithm,
Cipher  cipher 
)
static

注册自定义Cipher实现到算法注册表。

参数
algorithm算法名称。
cipherCipher对象实例。
返回
注册是否成功。

◆ transform()

byte [] transform ( byte []  input,
int  offset,
int  length 
)

对输入数据进行加密或解密转换。

参数
input输入字节数组。
offset输入数据的起始偏移量。
length输入数据的长度。
返回
转换后的字节数组,不能为空指针。
异常
std::out_of_range如果偏移量或长度超出范围。

◆ update()

int update ( byte []  input,
int  offset,
int  length 
)

更新输入数据,处理部分数据块。

参数
input输入字节数组。
offset输入数据的起始偏移量。
length输入数据的长度。
返回
已处理的数据长度。
异常
std::out_of_range如果偏移量或长度超出范围。

◆ updateAAD()

void updateAAD ( byte []  aad,
int  offset,
int  length 
)

更新附加认证数据(AAD),用于认证加密模式。

参数
aad附加认证数据字节数组。
offset数据起始偏移量。
length数据长度。
异常
std::out_of_range如果偏移量或长度超出范围。