def priv_password_equal?(input_pw, is_localized=false)
      input_pw = input_pw.to_s unless input_pw.is_a?(String)
      # If no input password, and no password present, true!
      return true if input_pw.empty? && priv_protocol == :none
      # Otherwise, if either one is missing, false!
      return false if input_pw.empty? || priv_protocol == :none
      # Otherwise, we have both input and configured passwords to compare
      current_pw = priv_password
      if current_pw.nil?
        fail "SNMP user #{@name} #{@engine_id} has priv #{priv_protocol} " \
             "but no password?\n" + @@node.get(command: 'show run snmp all')
      end

      if is_localized
        # In this case, the password is already hashed.
        hashed_pw = input_pw
      else
        # In this case passed in password is clear text while the running
        # config is hashed value. We need to hash the passed in clear text.

        # Create dummy user
        config_set('snmp_user', 'user', '', 'dummy_user', '',
                   "auth #{_auth_sym_to_str(auth_protocol)} #{input_pw}",
                   "priv #{_priv_sym_to_str(priv_protocol)} #{input_pw}",
                   '',
                   @engine_id.empty? ? '' : "engineID #{@engine_id}")

        # Retrieve password hashes
        dummyau = SnmpUser.auth_password('dummy_user', @engine_id)
        hashed_pw = SnmpUser.priv_password('dummy_user', @engine_id)
        if hashed_pw.nil?
          fail "SNMP dummy user dummy_user #{@engine_id} was configured " \
               "but password is missing?\n" \
               + @@node.get(command: 'show run snmp all')
        end

        # Delete dummy user
        config_set('snmp_user', 'user', 'no', 'dummy_user', '',
                   "auth #{_auth_sym_to_str(auth_protocol)} #{dummyau}",
                   "priv #{_priv_sym_to_str(priv_protocol)} #{hashed_pw}",
                   'localizedkey',
                   @engine_id.empty? ? '' : "engineID #{@engine_id}")
      end
      hashed_pw == current_pw
    end
def priv_password_equal?(input_pw, is_localized=false)
      input_pw = input_pw.to_s unless input_pw.is_a?(String)
      # If no input password, and no password present, true!
      return true if input_pw.empty? && priv_protocol == :none
      # Otherwise, if either one is missing, false!
      return false if input_pw.empty? || priv_protocol == :none
      # Otherwise, we have both input and configured passwords to compare
      current_pw = priv_password
      if current_pw.nil?
        fail "SNMP user #{@name} #{@engine_id} has priv #{priv_protocol} " \
             "but no password?\n" + @@node.get(command: 'show run snmp all')
      end

      if is_localized
        # In this case, the password is already hashed.
        hashed_pw = input_pw
      else
        # In this case passed in password is clear text while the running
        # config is hashed value. We need to hash the passed in clear text.

        # Create dummy user
        config_set('snmp_user', 'user', '', 'dummy_user', '',
                   "auth #{_auth_sym_to_str(auth_protocol)} #{input_pw}",
                   "priv #{_priv_sym_to_str(priv_protocol)} #{input_pw}",
                   '',
                   @engine_id.empty? ? '' : "engineID #{@engine_id}")

        # Retrieve password hashes
        dummyau = SnmpUser.auth_password('dummy_user', @engine_id)
        hashed_pw = SnmpUser.priv_password('dummy_user', @engine_id)
        if hashed_pw.nil?
          fail "SNMP dummy user dummy_user #{@engine_id} was configured " \
               "but password is missing?\n" \
               + @@node.get(command: 'show run snmp all')
        end

        # Delete dummy user
        config_set('snmp_user', 'user', 'no', 'dummy_user', '',
                   "auth #{_auth_sym_to_str(auth_protocol)} #{dummyau}",
                   "priv #{_priv_sym_to_str(priv_protocol)} #{hashed_pw}",
                   'localizedkey',
                   @engine_id.empty? ? '' : "engineID #{@engine_id}")
      end
      hashed_pw == current_pw
    end
Passwords are hashed and so cannot be retrieved directly, but can be
 checked for equality. This is done by creating a fake user with the
 password and then comparing the hashes