Guest User

Untitled

a guest
Mar 29th, 2014
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.32 KB | None | 0 0
  1. # Process message into chunks
  2. def chunkMessage( str )
  3.     nblk = ((str.length + 8) >> 6) + 1
  4.     blks = Array.new(nblk * 16) { 0 }
  5.  
  6.     i = 0
  7.     while i < str.length do
  8.         blks[i >> 2] |= str[i].ord << ((i % 4) * 8)
  9.         i += 1
  10.     end
  11.    
  12.     blks[i >> 2] |= 0x80 << ((i % 4) * 8)
  13.     blks[nblk * 16 - 2] = str.length * 8
  14.    
  15.     return blks
  16. end
Advertisement
Add Comment
Please, Sign In to add comment