April 23, 2019
Generating encryption id
Comments
(2)
April 23, 2019
Generating encryption id
Newbie 5 posts
Followers: 2 people
(2)

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.

2 Comments
2019-04-25 15:13:52
2019-04-25 15:13:52

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.

 

Like
(1)
>
Charlie Arehart
's comment
2019-04-29 07:06:51
2019-04-29 07:06:51
>
Charlie Arehart
's comment

Thank you Charlie Arehart

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>

Like
Add Comment