Preparing table for SHA-1
I try to code the SHA-1 algorithm. In my book they wrote that the algorithm needs array of 32 bit values. I has to have length of multiple of 16(it is easy but what values I suppose to add at the end of table), the last message bit has to be set and the last 64 bits represent the message length in big endian order. I get confused: last message is set or last 64 should represent length?

Convertion into 32 bit table, but then how to fill the rest of requirements corectly. I am really bad on these operations.

      public static int[] toIntArray(byte[] barr) { 
	        //Pad the size to multiple of 4 
	        int size = (barr.length / 4) + ((barr.length % 4 == 0) ? 0 : 1);       
	
	        ByteBuffer bb = ByteBuffer.allocate(size *4); 
	        bb.put(barr); 
	
	        //Java uses Big Endian. Network program uses Little Endian. 
	        bb.order(ByteOrder.BIG_ENDIAN); 
	        bb.rewind(); 
	        IntBuffer ib =  bb.asIntBuffer();         
	        int [] result = new int [size]; 
	        ib.get(result); 
	
	        return result; 
	}





Preparing table for SHA-1
===

I try to code the SHA-1 algorithm. In my book they wrote that the algorithm needs array of 32 bit values. I has to have length of multiple of 16(it is easy but what values I suppose to add at the end of table), the last message bit has to be set and the last 64 bits represent the message length in big endian order. I get confused: last message is set or last 64 should represent length?

Convertion into 32 bit table, but then how to fill the rest of requirements corectly. I am really bad on these operations.

      public static int[] toIntArray(byte[] barr) { 
	        //Pad the size to multiple of 4 
	        int size = (barr.length / 4) + ((barr.length % 4 == 0) ? 0 : 1);       
	
	        ByteBuffer bb = ByteBuffer.allocate(size *4); 
	        bb.put(barr); 
	
	        //Java uses Big Endian. Network program uses Little Endian. 
	        bb.order(ByteOrder.BIG_ENDIAN); 
	        bb.rewind(); 
	        IntBuffer ib =  bb.asIntBuffer();         
	        int [] result = new int [size]; 
	        ib.get(result); 
	
	        return result; 
	}




