I
intrader
I have a .NET interop assembly Hash.MD5Sum with two methods Identity and
GetMD5Sum.
I want to call the methods from ASP (JScript), The debugger tells me that
object oMD5Sum has only one method (ToString()). How do I get the
Identity and GetMD5Sum methods to be accessible?
I include the entire .net assembley followed by a snippet of the ASP code.
/////The code of the .NET assembly is:
using System;
using System.Text;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
[assembly:
GuidAttribute("3F7E9E2F-33DE-473e-BCEF-ABD161A5C2F4")]
namespace Hash
{
/// <summary>
/// Summary description for IHop.
/// </summary>
///
[GuidAttribute("66E6B7CB-6E8A-4396-A916-DB761AAAB65C")]
public interface IMD5Sum
{
string Identity();
string GetMD5Sum(string toDigest);
}
/// <summary>
/// This class provides the MD5Sum hash.
/// </summary>
[GuidAttribute("5D701679-CB67-4e23-A83B-099AC85B175E")]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]
[ProgIdAttribute("Hash.MD5Sum")]
public class MD5Sum
{
public MD5Sum()
{
}
// C# to convert a string to a byte array.
public static byte[] StrToByteArray(string str)
{
System.Text.ASCIIEncoding encoding=
new System.Text.ASCIIEncoding();
return encoding.GetBytes(str);
}
public string Indentity()
{
return "How are you doing?";
}
public string GetMD5Sum(string toDigest)
//Output: string<-> input: string //
{
return BitConverter.ToString(new
MD5CryptoServiceProvider().
ComputeHash(StrToByteArray(toDigest))).
Replace("-","").ToLower();
///End of the .Net Assembly
In the ASP I do the following:
////Code in the ASP
<script language="jscript" type="text/javascript" runat="server">
debugger;
var oMD5Sum = Server.CreateObject("Hash.MD5Sum");
var sIdentity = oMD5Sum.Identity();
var sDigest = oMD5Sum.GetMD5Sum("hey foo");
</script>
Thanks for your help!
GetMD5Sum.
I want to call the methods from ASP (JScript), The debugger tells me that
object oMD5Sum has only one method (ToString()). How do I get the
Identity and GetMD5Sum methods to be accessible?
I include the entire .net assembley followed by a snippet of the ASP code.
/////The code of the .NET assembly is:
using System;
using System.Text;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
[assembly:
GuidAttribute("3F7E9E2F-33DE-473e-BCEF-ABD161A5C2F4")]
namespace Hash
{
/// <summary>
/// Summary description for IHop.
/// </summary>
///
[GuidAttribute("66E6B7CB-6E8A-4396-A916-DB761AAAB65C")]
public interface IMD5Sum
{
string Identity();
string GetMD5Sum(string toDigest);
}
/// <summary>
/// This class provides the MD5Sum hash.
/// </summary>
[GuidAttribute("5D701679-CB67-4e23-A83B-099AC85B175E")]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]
[ProgIdAttribute("Hash.MD5Sum")]
public class MD5Sum
{
public MD5Sum()
{
}
// C# to convert a string to a byte array.
public static byte[] StrToByteArray(string str)
{
System.Text.ASCIIEncoding encoding=
new System.Text.ASCIIEncoding();
return encoding.GetBytes(str);
}
public string Indentity()
{
return "How are you doing?";
}
public string GetMD5Sum(string toDigest)
//Output: string<-> input: string //
{
return BitConverter.ToString(new
MD5CryptoServiceProvider().
ComputeHash(StrToByteArray(toDigest))).
Replace("-","").ToLower();
///End of the .Net Assembly
In the ASP I do the following:
////Code in the ASP
<script language="jscript" type="text/javascript" runat="server">
debugger;
var oMD5Sum = Server.CreateObject("Hash.MD5Sum");
var sIdentity = oMD5Sum.Identity();
var sDigest = oMD5Sum.GetMD5Sum("hey foo");
</script>
Thanks for your help!