• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Encrypt Password Problem

New Here ,
May 02, 2006 May 02, 2006

Copy link to clipboard

Copied

I am encrypting a password in my application. The problem I am having is that one of my encrypted passwords starts with a single quote. This is blowing up my SQL queries. Is there a way to force CF to only use alpha or numeric characters?
TOPICS
Advanced techniques

Views

499

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , May 02, 2006 May 02, 2006
I had a similar problem. I found that if I used <cfqueryparam> on the password parameter, when checking it against the encrypted value in the database, the error went away. Below is a sample of the logon verification query that I use in one of my applications where I use encrypted passwords.

<cfquery name="Q1" DATASOURCE="#dbname#">
SELECT admin_id, expire_date, access_level, enabled
FROM admin
WHERE LOWER(logon_name) = LOWER('#form.v_logon_name#')
AND password = <cfqueryparam value = "#encrypt...

Votes

Translate

Translate
Mentor ,
May 02, 2006 May 02, 2006

Copy link to clipboard

Copied

I had a similar problem. I found that if I used <cfqueryparam> on the password parameter, when checking it against the encrypted value in the database, the error went away. Below is a sample of the logon verification query that I use in one of my applications where I use encrypted passwords.

<cfquery name="Q1" DATASOURCE="#dbname#">
SELECT admin_id, expire_date, access_level, enabled
FROM admin
WHERE LOWER(logon_name) = LOWER('#form.v_logon_name#')
AND password = <cfqueryparam value = "#encrypt(form.v_password, cookie.pw_seed)#" CFSQLType = "CF_SQL_VARCHAR">
</cfquery>

Phil

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 02, 2006 May 02, 2006

Copy link to clipboard

Copied

one way around this is to urlencode the encrypted password
URLEncodedFormat(Encrypt(arguments.password, application.encKey))

and the decode if needed
Decrypt(URLDecode(Trim(userinfo.password)), application.encKey)

HTH
--
Tim Carley
www.recfusion.com
info@NOSPAMINGrecfusion.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 02, 2006 May 02, 2006

Copy link to clipboard

Copied

Wouldn't the PreserveSingleQuotes function be useful here also?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 02, 2006 May 02, 2006

Copy link to clipboard

Copied

LATEST
Not really, as you are likely to get "special" characters other than single quotes that may cause you problems, so using CFQUERYPARAM seems to do the trick, at least it did for me.

Phil

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation