Are you certain that the VB.NET output is SHA-1 and that you've copied the
complete input string correctly?
Here's how I would do what you've got in VB with CF:
<cfscript>
testString = "SENTRYORD01154321SENTRYORD01154321";
HashValue = Hash(testString,'SHA-1','UTF-8');
sa = ToBase64(BinaryDecode(HashValue,'HEX'));
</cfscript>
<cfoutput>#sa#</cfoutput>
But that is producing "MDVpYVMX3JmnAp77FaAaQ6WtOdM=" not
"WbwSWEBzPqgo9C4nZmGwHhd/FBQ=".
(Though perhaps this is because of different implementations of SHA in Java
compared to .NET, I've no idea)
> 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:254952
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4