Created
June 28, 2011 11:14
-
-
Save vsalbaba/1050924 to your computer and use it in GitHub Desktop.
Generovani hesla z mysql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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