Method: Nis::Util::Convert.ua2words

Defined in:
lib/nis/util/convert.rb

.ua2words(ua, ua_length) ⇒ WordArray

Convert an Uint8Array to WordArray

Parameters:

  • ua (Array)
    • An Uint8Array

  • uaLength (number)
    • The Uint8Array length

Returns:

  • (WordArray)


69
70
71
72
73
74
75
76
77
# File 'lib/nis/util/convert.rb', line 69

def self.ua2words(ua, ua_length)
  ua[0, ua_length].each_slice(4).map do |chunk|
    x = chunk[0] * 0x1000000 +
      chunk[1] * 0x10000 +
      chunk[2] * 0x100 +
      chunk[3] * 0x1
    x > 0x7fffffff ? x - 0x100000000 : x
  end
end