Results 1 to 4 of 4

Thread: "String reference not set to " - Encrytion

  1. #1
    Join Date
    Mar 2005
    Posts
    163
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default "String reference not set to " - Encrytion

    I am at my wits end with Encrytion today, having started off with passwords that apparently do not match to finally closing down onto this issue.

    I have a class Function which very simply encrypts a password (no Salt), but when I try to pass a string to the function, i get the error:

    "String reference not set to an instance of a String.
    Parameter name: s"

    If I pass a 'raw' string, ie encrypt("thisword") it works ok, but not if I do encrypt(avariable)

    My class is
    ##################################################
    Imports Microsoft.VisualBasic
    Imports System.Security.Cryptography
    Imports System.Text

    Public Class DotShop
    Public Function Encrypt(ByVal Password As String) As Byte()
    Dim md5Hasher As New MD5CryptoServiceProvider
    Dim encrypted As Byte()
    Dim encoder As New UTF8Encoding()

    encrypted = md5Hasher.ComputeHash(encoder.GetBytes(Password))

    Return encrypted
    End Function
    End Class
    ##################################################
    and the code that calls the calls is

    ##################################################
    Partial Class register

    Inherits System.Web.UI.Page

    Dim pWord As String

    Protected Sub doSomething()
    pWord = txtPassword.Text
    End Sub

    Protected Sub btnFinalSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    'blah blah set up the db connection etc

    cmdInsert.Parameters.Add("@Password", DotShop.Encrypt(pWord))

    'blah blah execute it
    End Sub
    End Class
    ##################################################

    I found that I caanot simply do Encrypt(txtpassword.text) becuase the textbox is actually in a different panel and for some reason I cannot reference it like so becuase the panel is 'hidden' when the FinalSubmit is clicked. This nenver caused an issue in net1.1 btw, must be some new security feature in 2.0. Anyway, thnkas for taking the time.!

  2. #2
    Join Date
    Jun 2005
    Posts
    1,081
    Thanks
    4
    Thanked 15 Times in 15 Posts

    Default

    I think the issue is the hidden panel and the fact that pword is getting it's value from a different sub routine which is not called during the btnSubmitfinal_Click process.

    What I would do is store the pword in Viewstate to ensure it is available any time I want.

  3. #3
    Join Date
    Feb 2004
    Posts
    4,901
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Quote Originally Posted by Sol
    I think the issue is the hidden panel and the fact that pword is getting it's value from a different sub routine which is not called during the btnSubmitfinal_Click process.
    Yep - your accessing the variable from two different scopes...
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  4. #4
    Join Date
    Mar 2005
    Posts
    163
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok kool, Ill add it to view state, previously I did'nt use pWord, just encrypted txtpassword.text directly, but the hidden panel and password box thing is definalty a new 'feature'.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. HOWTO: Create a Temporary "Pre DNS Propagation" URL
    By Warren Ashcroft in forum Technical Support
    Replies: 5
    Last Post: 29th April 2008, 07:52 AM
  2. "Super" sort of cheap hosting option????
    By jigsawsrusdotcom in forum Sales and Service Feature Enquiries
    Replies: 2
    Last Post: 28th March 2006, 10:38 PM
  3. $getPage = getenv("SCRIPT_NAME");
    By Space Cowboy in forum PHP
    Replies: 16
    Last Post: 24th March 2006, 09:01 AM
  4. Is there is a reason that redfox don't install "Helm Extensions" add onn
    By HostCan in forum Customer Feedback and Suggestions
    Replies: 1
    Last Post: 25th July 2005, 06:51 PM
  5. Billing "Access is denied"
    By Mark Voss in forum Sales and Service Feature Enquiries
    Replies: 5
    Last Post: 4th April 2005, 08:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •