Ah, it looks like VB.NET uses 160-bit SHA-1, which is 20 bytes/characters, 
compared to CF's 28 characters.

As pointed out by Greg, Adobe Exchange has a SHA-1 custom tag, and that is 
160-bit so should match the value that VB.NET is producing:
http://www.adobe.com/cfusion/exchange/index.cfm#view=sn106&viewName=Exchange%20Search%20Details&loc=en_us&authorid=34950683&page=0&scrollPos=0&subcatid=0&snid=sn106&itemnumber=4&extid=1002094&catid=0


> 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.
> ToCharArray))
           
> 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:255042
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to