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

Number encryption, converting ASP code to Coldfusion

New Here ,
Jun 14, 2006 Jun 14, 2006

Copy link to clipboard

Copied

Hi guys,

I was wondering if someone could help me out here.....

I have currently got code in ASP VbScript that is taking a number, and encrypting it:

Function EncryptText(strText, strPwd)

For i = 1 To Len(strText)
c = Asc(Mid(strText, i, 1))
c = c + Asc(Mid(strPwd, (i Mod Len(strPwd)) + 1, 1))
strBuff = strBuff & Chr(c And &HFF)
Next
EncryptText = strBuff

End Function

I need to convert it to Coldfusion for another site, so far I have:

<cfset strBuff = "">
<cfset Password = "@$.##j">
<cfset cardnumber = int(#MyList#)>
<cfloop index="i" from="1" to="#len(cardnumber)#">
<cfset c = Asc(Mid(#cardnumber#, i, 1))>
<cfset c = #c# + Asc(Mid(#Password#, (i Mod Len(#Password#)) + 1, 1))>
<cfset strBuff = strBuff & Chr(#c# & 255)>
</cfloop>

But for some reason the code doesnt seem to work, can anyone help??

Many thanks in advance
TOPICS
Advanced techniques

Views

258

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
Enthusiast ,
Jun 14, 2006 Jun 14, 2006

Copy link to clipboard

Copied

LATEST
This is a bit of a worry
<cfset cardnumber = int(#MyList#)>

Int
Returns the closest integer that is smaller than a number

Then in the loop you do
="#len(cardnumber)#">

Which if the value of cardnumber was 13, then the len is 2

What is MyList, it's not in the vb script one ?
See code attached

Ken

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