3 Replies Latest reply on May 20, 2013 1:50 PM by mkane1

    hash ID from cfmail?

    newcf Level 1



      i am uisng CF7 and develope the page with  have cfmail send the url to customer but i don't want them to see the ID from the link.  Is there the way to hash, encode, decode for not letting them see an ID but when they click on the link, the ID will propertly decode and retireve the record from the table?





        • 1. Re: hash ID from cfmail?
          mkane1 Level 1

          Yes, you could use the Hash function (added in MX7). Since you can't "unhash", you would need to Hash the ID and store the resulting string somewhere. The email to the customer would contain the string as a parameter in the link you send, and when they click the link you compare the value with those you saved.


          1) Add a field to your database table containing the IDs, call it something like IDHashed

          2) Do a query to get all your ID values and loop over the result

          3) cfset ThisHashedString = Hash(current_ID_value, "SHA") and save the result in the field you added, i.e. IDHashed

          4) When creating the link to go in the email, use the hashed string as a parameter

          5) When someone clicks the link, it goes to your page that sees the parameter, hopefully validates/sanitizes it, and queries your database for a matching value in the field you added in step 1.


          I'm all for "if it ain't broke don't fix it", I'm still running CF 9.0.1. But MX7? That's really old....

          • 2. Re: hash ID from cfmail?
            newcf Level 1

            i guess i can use uuid instead?

            • 3. Re: hash ID from cfmail?
              mkane1 Level 1

              Do you mean use the CreateUUID function? Yes, you could. I'm not sure when that was added, the Livedocs don't say when a function was added, as they do for tags. Whatever works in MX7 should suffice.