我从中提取了ASP的代码,并将它的所有密码编码到RC4中,编码功能如下:
function rc4(byref thestr, byref thekey)
dim asciiarray(255)
dim keyarray(255)
if isnull(thestr) then exit function
if len(thekey)=0 then exit function
if len(thestr)=0 then thestr=" "
if len(thestr)=0 then exit function
zxlen=len(thekey)
我使用了netty 3.6,我想通过任何区域将文件数据写入通道,并进行加密。
我在一个通道上用FileRegion写了一个文件数据,没有任何问题,工作很好,也不吃我的内存,但是我想要读取块块(由RC4编写)(块大小为512),然后再转到通道,我使用了以下代码:
if (e.getChannel().isWritable()) {
FileInputStream fin = new FileInputStream(file);
byte[] data = new byte[512];
for (int i = 512; i < file.length
我自己实现了rc4算法,在对文本进行加密和解密的过程中非常有魅力,当我试图对图像进行加密/解密时,问题就出现了。我的输出图像总是不可读。不会引发任何异常。我不确定是加密还是解密不起作用,或者两者兼而有之。你的帮助将不胜感激。
RC4 Class
公共类RC4 {
private byte[] S = new byte[256];
public RC4 (byte[] key) {
byte[] T = new byte[256];
int keylen, j;
byte t;
for (int i = 0; i < 256; i++) {
我有一个
String X = 0110100001100101011011000110110001101111530940929e959001f70dd4da5f5cc3b373165781
我首先通过X.getBytes()将字符串X变成一个字节[];然后使用以下方法进行RC4加密。
public static byte[] RC4(byte[] x,byte[] keyBytes)
{
byte[] e = null;
try
{
SecureRandom sr = new SecureRandom(keyBytes);