Hi dear friends,
My current problem regarding inputstream value processing . I don't get the block level full value as shown in loop.I got last byte value only

           cipher.init(cipherMode, publicKey);
             byte[] encText = null;
            while ( (bufl = inputReader.read(buf)) != -1)
        {
             encText =  RSAEncryptUtil.encrypt(RSAEncryptUtil.copyBytes(buf,bufl),(PublicKey) publicKey);
         }

         String hexString = HexEncodeDecode.encode(encText);

I need to get encText byte[] value with full encrypted file value . Any body have a fast solution please..

Thanks
Anes

Recommended Answers

All 2 Replies

I don't do Java but could it be that you need:

while ( (bufl += inputReader.read(buf)) != -1)

or something along those lines?

because you encrypt every time the while loop runs and you don't add the new information but you overwrite it, so when you assign to encText, don't assign just the new value but append it on whatever was already in there

Kind of the same as

int values[]
while(i < 10)
    values[values.length] = i
    i++
print values //at this point you have all values of i 


while if it was like this
int values[]
while(i < 10)
    values = i
    i++
it will have only the last value of i
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.