{"record":{"id":"e4a5405a908e03ba","repo":"theforeman/foreman","slug":"unsupported-password-hash-function-s","errorCode":null,"errorMessage":"Unsupported password hash function '%s'","messagePattern":"Unsupported password hash function '(.+?)'","errorType":"exception","errorClass":"Foreman::Exception","httpStatus":null,"severity":"error","filePath":"app/services/password_crypt.rb","lineNumber":21,"sourceCode":"class PasswordCrypt\n  ALGORITHMS = {'SHA512' => '$6$', 'SHA256' => '$5$', 'Base64' => '', 'Base64-Windows' => ''}\n  # Matches ENCRYPT_METHOD in /etc/login.defs on EL6+\n  # When changing this, be sure to add a migration for operatingsystems'\n  # default value\n  DEFAULT_HASH_ALGORHITHM = 'SHA512'\n\n  if Foreman::Fips.md5_available?\n    ALGORITHMS['MD5'] = '$1$'\n  end\n\n  def self.generate_linux_salt\n    # Linux crypt accepts maximum 16 [a-zA-Z0-9./] characters\n    SecureRandom.alphanumeric(16)\n  end\n\n  def self.passw_crypt(passwd, hash_alg = nil)\n    hash_alg ||= DEFAULT_HASH_ALGORHITHM\n    raise Foreman::Exception.new(N_(\"Unsupported password hash function '%s'\"), hash_alg) unless ALGORITHMS.has_key?(hash_alg)\n\n    case hash_alg\n    when 'Base64'\n      result = Base64.strict_encode64(passwd)\n    when 'Base64-Windows'\n      result = Base64.strict_encode64(\"#{passwd}AdministratorPassword\".encode('utf-16le'))\n    else\n      result = passwd.crypt(\"#{ALGORITHMS[hash_alg]}#{generate_linux_salt}\")\n    end\n\n    result.force_encoding(Encoding::UTF_8) if result.encoding != Encoding::UTF_8\n    result\n  end\n\n  def self.grub2_passw_crypt(passw)\n    passw_crypt(passw, 'SHA512')\n  end\n","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/theforeman/foreman/blob/6b05625475cfe6aac31a88f8c8ee6e62e4efe620/app/services/password_crypt.rb#L3-L39","documentation":"Error \"Unsupported password hash function '%s'\" thrown in theforeman/foreman.","triggerScenarios":"Thrown at app/services/password_crypt.rb:21 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6b05625475cfe6aac31a88f8c8ee6e62e4efe620","analyzedAt":"2026-08-23T17:46:34.094Z","schemaVersion":2},"datasetVersion":"2026-08-23T21:17:23.414Z"}