portal entry

select a category, or use search below
(searches all categories and all time range)

Generating encryption id

| View in Portal
April 23, 2019 06:56:28 AM GMT
<p>I have to generate encrypted id to every unique id and need to attach it to my url.That encrypted id should not be repeated..can u help me with this please.</p>
<p>The post <a rel="nofollow" href="https://coldfusion.adobe.com/2019/04/generating-encryption-id/">Generating encryption id</a> appeared first on <a rel="nofollow" href="https://coldfusion.adobe.com">ColdFusion</a>.</p>
Labels: ColdFusion, Development Services, Question, development services, question


It will help to clarify things. what would the "unique id" be? Something you already have in your app? or something you need to create? If you need to create one, you could use CF's createuuid() function, to create a unique id (indeed, a "universally unique id", which uuid euphemistically stands for). I assume you'd be creating that "unique id" for something, so that so that you'd store it in a database record about that thing.  Note also that most databases WILL create a unique id as the primary key for every record in a table--though the value is only unique to that table. Some can be told to create a uuid for that primary key, for what that's worth. Then if you are going to pass such an id on a URL, you should use the urlencodedformat() function around that. But then you say you also want to encrypt it. Do you mean encrypting what you are passing on the URL? There are various CF functions for encryption (where you pass it a value and a key, and perhaps a salt), and various encryption algorithms. A very important question is who or what will be RECEIVING that encrypted value, and how will it decrypt what you pass? and how will it know the key (and solt) used to encrypt it? What you are asking may seem simple, but it can turn complex quickly. Let us know more, and I and others can help. And it may help to show an example of the kidn of URL you are trying to build, already.  
Comment by Charlie Arehart
2014 | April 25, 2019 03:13:52 PM GMT
Thank you <a href="https://coldfusion.adobe.com/profile/Charlie%20Arehart">Charlie Arehart</a> This my code..In generatekey function i need to create key as per my requirement.My key should be surveyID_inviteArray[j].But the problem is the generateKey method only takes an algorithm as parameter..So any other method which is there to create our own key..help me with this..   <cfset InviteArray=[1,2,3,4,5,6,7,8,9,10]> <cfset surveyID=1> <cfset encryptArray=arrayNew(1)/> <cfloop from="1" to="#arraylen(InviteArray)#" index="j"> <cfset inviteandandSurvey=surveyID&InviteArray[j]> <cfset encryptionKey = generateSecretKey( "AES" ) /> <cfset EncryptedSurveyID = encrypt(inviteandandSurvey,encryptionKey,"AES","hex") /> <cfset decoded = decrypt(EncryptedSurveyID,encryptionKey,"AES","hex") /> <cfset encryptArray[j]="#EncryptedSurveyID#"> <cfdump var="#encryptArray[j]#"></br> </cfloop>
2028 | April 29, 2019 07:06:51 AM GMT