0

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

3
Contributors
2
Replies
14
Views
2 Years
Discussion Span
Last Post by Slavi
0

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

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

or something along those lines?

Edited by DaveAmour

0

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

Edited by Slavi

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.