Be careful with encryption moving from .Net to CF and vice versa. Just
because the one names the algorithm the same way as the other it doesn't
follow that you can just encrypt in one and decrypt in the other.

For example, the MD5 hash used in CF is a short version that uses
hexedecimal notation. Even if you expand it, the one returned by VB.Net 2005
is not the same, i.e. VB.Net MD5("bob") != CF MD5("bob") even after
converting both hashes to the long format. Didn't have the CF7 at the time
thus I didn't test other encryption algs that came with CF vis .Net stock
methods, but would not be surprised if they didn't work well with each
other.

You will need to go down to Java on CF and get classes that are translated
to VB.Net or vice versa.

TK
http://www.tomkitta.com

-----Original Message-----
From: Juman Lop [mailto:[EMAIL PROTECTED]
Sent: Sunday, October 01, 2006 11:21 PM
To: CF-Talk
Subject: Hash Sha-1


Can anyone help me to convert this VB.NEt code to Coldfusion code. I'm
trying to do it but the output is dosn't same.
VB.NET cod:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      Input: SENTRYORD01154321SENTRYORD01154321
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Imports System.Security.Cryptography
           Private Function ComputeHash(ByVal Key As String) As String
           Dim objSHA1 As New SHA1CryptoServiceProvider
           objSHA1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(Key.ToChar
Array))
           Dim buffer() As Byte = objSHA1.Hash
           Dim HashValue As String = System.Convert.ToBase64String(buffer)
           Return HashValue
    End Function
'''''''''''''''''''''''''''''''''''''''''
Output:WbwSWEBzPqgo9C4nZmGwHhd/FBQ=
''''''''''''''''''''''''''''''''''''''''

My coldfusion code seem to be:
<cfscript>
    testString = "#create#";
    JObj = createobject("java", "java.lang.String").init(testString);
    asd=jObj.getBytes("UTF-8");
    hashvalue=hash("asd","md5");
    sa=ToBase64(hashvalue);
</cfscript>
<cfoutput>#sa#</cfoutput>

Help me to solve this problem.

Thank You
Aerjoel




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:254940
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to