From: Bishop on
Here is a alternate way to calculate a MD5 Hash:

http://www.scriptbox.at.tt/index.php?search=Calculate%20MD5%20Hash.vbs

alternate Link:

http://vbscript.boris-toll.at/index.php?search=Calculate%20MD5%20Hash.vbs



"Anthony Jones" wrote:

>
>
> <jeffhowse(a)gmail.com> wrote in message
> news:bd45badb-7e60-452a-90c2-527b9b5ef0ac(a)y38g2000hsy.googlegroups.com...
> On Sep 8, 2:06 am, "ekkehard.horner" <ekkehard.hor...(a)arcor.de> wrote:
> > jeffho...(a)gmail.com schrieb:
> >
> >
> >
> >
> >
> > > I have scoured the Net and haven't had any luck finding what I need.
> > > I've been asked to take a C# SSO web page and convert it to a
> > > VBScript. The problem I'm having is that in the SSO web page, we're
> > > taking a user name and appending it to a shared key, turning it into a
> > > UTF8 byte array, MD5 hashing it, and then converting that to a Base64
> > > string.
> >
> > > I've tried using the MD5 functions that I've found in several
> > > different places but none return the string I expect without doing the
> > > UTF8 byte array and the Base64 conversion. I've tried creating
> > > objects through COM of the .NET dlls I use in the SSO web page
> > > (System.Encryption.UTF8 and
> > > System.Security.Cryptography.MD5CryptoServiceProvider) but I keep
> > > getting errors when trying to call the correct functions and it says
> > > they don't exist even though I can check certain properties to ensure
> > > the object was created correctly.
> >
> > Did you add position numbers to the names of polymorph function as
> > described in
> > http://blog.opennetcf.org/afeinman/PermaLink,guid,aa53e23d-b8e5-4015-...
> >
> > ? Sometimes parameters need special treatment (e.g. passing per value)
> > too.
> >
> >
> >
> > > Am I barking up the wrong tree by going about it this way? I could
> > > easily create a DLL exposed to COM that I could use but at that point
> > > I might as well create an executable app.
> >
> > > I could really use some help with this. I've never worked that much
> > > with VBScript before so I'm playing in waters that aren't that
> > > familiar to me. Can anyone give me some guidance on this? Any help
> > > would be greatly appreciated.- Hide quoted text -
> >
> > - Show quoted text -- Hide quoted text -
> >
> > - Show quoted text -
>
> That was it! Thanks! Had to use GetBytes_4 and ComputeHash_2.
> You've saved me a ton of time. Now I'm struggling with using the
> equivalent of Convert.ToBase64String. Any help here would be greatly
> appreciated as well. Thanks in advance!
> >>>>
>
> Out of curiosity I was playing around with this as well. However not with
> much success:-
>
> Option Explicit
>
> Dim oBase64 : Set oBase64 =
> CreateObject("System.Security.Cryptography.ToBase64Transform")
> Dim oUTF8 : Set oUTF8 = CreateObject("System.Text.UTF8Encoding")
> Dim oMD5 : set oMD5 =
> CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider")
>
> Dim abyt : abyt = oUTF8.GetBytes_4("Hello World")
>
> oMD5.Initialize()
>
> abyt = oMD5.ComputeHash_2(abyt)
>
> MsgBox oBase64.TransformFinalBlock(abyt, 0, Len(abyt))
>
> I get an Invalid procedure call or argument on ComputeHash_2.
>
>
> --
> Anthony Jones - MVP ASP/ASP.NET
>
>
From: ekkehard.horner on
Anthony Jones schrieb:
[...]
> Out of curiosity I was playing around with this as well. However not
> with much success:-
>
> Option Explicit
>
> Dim oBase64 : Set oBase64 =
> CreateObject("System.Security.Cryptography.ToBase64Transform")
> Dim oUTF8 : Set oUTF8 = CreateObject("System.Text.UTF8Encoding")
> Dim oMD5 : set oMD5 =
> CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider")
>
> Dim abyt : abyt = oUTF8.GetBytes_4("Hello World")
>
> oMD5.Initialize()
>
> abyt = oMD5.ComputeHash_2(abyt)

use
abyt = oMD5.ComputeHash_2( (abyt) )
to pass abyt per value

>
> MsgBox oBase64.TransformFinalBlock(abyt, 0, Len(abyt))

aBytes = oBase64.TransformFinalBlock( aBytes, 0, Len( aBytes ) )
==> Ungültiger Prozeduraufruf oder ungültiges Argument: 'oBase64.TransformFinalBlock'
(invalid procedure call or parameter)

aBytes = oBase64.TransformFinalBlock( (aBytes), 0, Len( aBytes ) )
==> Either offset did not refer to a position in the string, or there is an
insufficient length of destination character

aBytes = oBase64.TransformFinalBlock( (aBytes), 0, 1 )
==> no error

As I'm not familiar with this secret service stuff, it's over to you ...

>
> I get an Invalid procedure call or argument on ComputeHash_2.
>
>