Having trouble turning a returning the MD5 hash of a string


i have looked around online, haven't found helps. trying return md5 has of input string is. tried was, make byte array , store string info it, tried return has code it, doesn't work. exact error is:
system.indexoutofrangeexception: index outside bounds of array.
@ webservice1.service1.checkuser(string username, string userpass) in c:\users\garrett\documents\visual studio 2008\projects\webservice1\webservice1\service1.asmx.vb:line 20
here code:
imports system.web.services  imports system.web.services.protocols  imports system.componentmodel    ' allow web service called script, using asp.net ajax, uncomment following line.  ' <system.web.script.services.scriptservice()> _  <system.web.services.webservice(namespace:="http://tempuri.org/")> _  <system.web.services.webservicebinding(conformsto:=wsiprofiles.basicprofile1_1)> _  <toolboxitem(false)> _  public class service1      inherits system.web.services.webservice        <webmethod()> _      public function checkuser(byval username string, byval userpass string) string          dim userhash string          dim bytearray() byte          dim md5 system.security.cryptography.md5            integer = 1 userpass.length              bytearray(i) = cbyte(asc(userpass.chars(i)))          next            md5.initialize()          md5.computehash(bytearray, 0, userpass.length)          userhash = md5.gethashcode            return userhash      end function  end class
thanks.

here wrote 2 method in c#

using system;  using system.collections.generic;  using system.web;  using system.web.services;  using system.security.cryptography;  using system.text;    namespace webservice1  {      /// <summary>      /// summary description service1      /// </summary>      [webservice(namespace = "http://tempuri.org/")]      [webservicebinding(conformsto = wsiprofiles.basicprofile1_1)]      [system.componentmodel.toolboxitem(false)]      public class service1 : system.web.services.webservice      {            [webmethod]          public string helloworld()          {              return "hello world";          }          [webmethod]          public string hashpassword(string password)          {              md5 md5 = md5.create();              byte[] bts = md5.computehash(encoding.ascii.getbytes(password));              stringbuilder sb = new stringbuilder();              foreach (byte bt in bts)              {                  sb.append(bt.tostring("x").padleft(2,'0'));              }              return sb.tostring();          }          [webmethod]           public string hashpassword1(string password)          {              return system.web.security.formsauthentication.hashpasswordforstoringinconfigfile(password, "md5");          }      }  }  

i'd meet friends develop c# . icq:422269376


Archived Forums A-B  >  ASMX Web Services and XML Serialization



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'