Method: String#to_i32a
- Defined in:
- lib/thefox-ext/ext/string.rb
#to_i32a ⇒ Object
Convert a String to an Integer 32-bit Array.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/thefox-ext/ext/string.rb', line 44 def to_i32a len = self.length len_w = (len >> 2) + (len & 0x3).to_b.to_i out = (0..(len_w - 1)).map{ |n| [n, 0] }.to_h i = 0 self.split('').each do |s| out[i >> 2] |= (s.ord << ((3 - (i & 0x3)) << 3)) i += 1 end out end |