Reputation: 320
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
Upvotes: 0
Views: 597
Reputation: 63084
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.
Upvotes: 1
Reputation: 628
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.
Upvotes: 4
Reputation: 178263
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.
Upvotes: 6