Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. private List<BigInteger> chunkWord(BigInteger sticked, final int chunkSize)
  2.             throws Exception {
  3.         List<BigInteger> list = new ArrayList<BigInteger>();
  4.  
  5.         int lenghtOfBigWord = sticked.bitLength();
  6.         while(lenghtOfBigWord%chunkSize!=0){
  7.             lenghtOfBigWord++;
  8.         }
  9.        
  10.         int rounds = lenghtOfBigWord/chunkSize;
  11.         for(int i=1;i<=rounds;i++){
  12.             BigInteger value = valueOf(0);
  13.             for(int ii=i*chunkSize-chunkSize;ii<i*chunkSize;ii++){
  14.                 boolean bit = sticked.testBit(ii);
  15.                 if(bit){
  16.                     value = value.setBit(ii);
  17.                 }
  18.             }
  19.             value = value.shiftRight((i-1)*chunkSize);
  20.             list.add(value);
  21.         }
  22.         return list;
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement