module RbNaCl::Util

def zero_pad(n, message)

Returns:
  • (String) - A string, n bytes long

Raises:
  • (RbNaCl::LengthError) - If the string is too long

Parameters:
  • message (String) -- the message to be padded
  • n (Integer) -- The length of the resulting string
def zero_pad(n, message)
  len = message.bytesize
  if len == n
    message
  elsif len > n
    raise LengthError, "String too long for zero-padding to #{n} bytes"
  else
    message + zeros(n - len)
  end
end