Question

i have this program that encrypt using a DES key in CBC mode , i need an IV:

 for(double ii=0;ii<9999999999999999;ii++)
                    {

                        String IIV=String.valueOf(ii);
                        IV=String.valueOf(ii);

                        for(int x=0;x<(16-IIV.length());x++)
                        {
                          IV=("0"+IV);  
                        }

                   Encrypt.ENC(Secretkey,IV,"Hi");

                    }

i tried to use double and long in the for loop and i still cant initialise the value 9999999999999999 to ii since the IV should be from 0000000000000000 to 9999999999999999

Was it helpful?

Solution 4

ok i tried this:

for(long int i=0;i<((10e16)-1);i++)

it worked

OTHER TIPS

The integer literal 9999999999999999 is too large to be represented as an int. Use a long literal, with a L suffix:

for(double ii=0;ii<9999999999999999L;ii++)

By the way, that is a long loop. That will run for a very long time.

At 10,000 iterations per second, we're talking approximately 32,000 years to run that loop. I think you need to rethink what you're trying to do.

9999999999999999 needs 54 bits to represent, which is out of the range of a 32 bit integer. Java integers are signed, so a positive number has to be less than 2^31. You could use long which has a positive range of 2^63.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top