初学java,在研究软件时遇到了RSA 密钥长度2048的加密, 加密blocksize的长度是多少,解密blocksize的是长度256。求以下的解密方法对应加密方法,谢谢!
public static byte[] decode_sun(Key key, byte[] data, int blocksize) throws ErrorS{
byte[] returnStr = null;
ByteArrayOutputStream out = new ByteArrayOutputStream(data.length);
try {
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(2, key);
int position = 0;
int length = data.length;
boolean more = true;
while(more) {
if (position + blocksize <= length) {
out.write(cipher.doFinal(data, position, blocksize));
position += blocksize;
} else {
more = false;
}
}
if (position < length) {
out.write(cipher.doFinal(data, position, length - position));
}
byte[] returnStr = out.toByteArray();
return returnStr;
} catch (Exception ) {
throw new ErrorS(ErrorCode.error_105231.getError());
}
}
你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,目前超出我们的服务范围,暂时无法为您解答。
首次提问人员可免费体验一次有问必答服务。目前首次提问的问题服务范围为:编程语言、Java开发、python、数据库、前端开发 领域专业技术问题,为您提供问题的解决思路和指导。
不提供源码代写、项目文档代写、论文代写、作业题目代写、安装包资源发送或安装、软件使用指导等服务。
我们后续会持续优化,扩大我们的服务范围,为您带来更好地服务。