Skip to content

Instantly share code, notes, and snippets.

@vsalbaba
Created June 28, 2011 11:14
Show Gist options
  • Save vsalbaba/1050924 to your computer and use it in GitHub Desktop.
Save vsalbaba/1050924 to your computer and use it in GitHub Desktop.
Generovani hesla z mysql
def generate_mysql_hash(password)
# pouze pokud bezime na MySQL
if ActiveRecord::Base.connection.adapter_name == "MySQL" then
# prohnat sql cistici funkci proti sql_injection
parameters = ActiveRecord::Base.send :sanitize_sql_array, ["password('%s')", password]
ActiveRecord::Base.connection.execute("select #{parameters}").fetch_row.first
else
password
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment