Results 1 to 8 of 8

Thread: algorithms

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Posts
    307

    algorithms

    how would i take text from a textbox, put it through a agrorythem and then write the agrorythem result to the registry?
    Last edited by cdubb07; Nov 2nd, 2005 at 09:00 AM.
    "Anybody can get angry or sad and frown but it takes a person with character to smile when times are hard."

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: agrorythems

    Are you talking about angry music, or do you mean an algorithm? An algorithm is just a method of performing some calculation, so you need to implement it yourself in code. That means you would pass the Text property of the TextBox to a function you have written that implements the algorithm and then write the result to the registry. I KNOW you know how to write to the registry, right?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Posts
    307

    Re: agrorythems

    lol, my bad, algrorithm, i'm using it to encrypt my password, i think i got it but can you give me a example, and yes i do know how to write to the registry lol.
    "Anybody can get angry or sad and frown but it takes a person with character to smile when times are hard."

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: algorithms

    Here is an example from freevbcode.com,

    VB Code:
    1. Pubilc Function WriteToRegistry(ByVal _
    2.     ParentKeyHive As RegistryHive, _
    3.     ByVal SubKeyName As String, _
    4.     ByVal ValueName As String, _
    5.     ByVal Value As Object) As Boolean
    6.  
    7. 'DEMO USAGE
    8. 'Dim bAns As Boolean
    9. 'bAns = WriteToRegistry(RegistryHive.LocalMachine, "SOFTWARE\MyCompany\MyProgram\", "ProgramHasRunBefore", "Y")
    10. 'Debug.WriteLine("Registry Write Successful: " & bAns)
    11.  
    12.         Dim objSubKey As RegistryKey
    13.         Dim sException As String
    14.         Dim objParentKey As RegistryKey
    15.         Dim bAns As Boolean
    16.  
    17.  
    18.         Try
    19.  
    20.             Select Case ParentKeyHive
    21.                 Case RegistryHive.ClassesRoot
    22.                     objParentKey = Registry.ClassesRoot
    23.                 Case RegistryHive.CurrentConfig
    24.                     objParentKey = Registry.CurrentConfig
    25.                 Case RegistryHive.CurrentUser
    26.                     objParentKey = Registry.CurrentUser
    27.                 Case RegistryHive.DynData
    28.                     objParentKey = Registry.DynData
    29.                 Case RegistryHive.LocalMachine
    30.                     objParentKey = Registry.LocalMachine
    31.                 Case RegistryHive.PerformanceData
    32.                     objParentKey = Registry.PerformanceData
    33.                 Case RegistryHive.Users
    34.                     objParentKey = Registry.Users
    35.  
    36.             End Select
    37.  
    38.  
    39.             'Open
    40.             objSubKey = objParentKey.OpenSubKey(SubKeyName, True)
    41.             'create if doesn't exist
    42.             If objSubKey Is Nothing Then
    43.                 objSubKey = objParentKey.CreateSubKey(SubKeyName)
    44.             End If
    45.  
    46.  
    47.             objSubKey.SetValue(ValueName, Value)
    48.             bAns = True
    49.         Catch ex As Exception
    50.             bAns = False
    51.  
    52.         End Try
    53.  
    54.         Return True
    55.  
    56.     End Function

    (Imports Microsoft.Win32)

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: agrorythems

    Quote Originally Posted by jmcilhinney
    Are you talking about angry music, or do you mean an algorithm? An algorithm is just a method of performing some calculation, so you need to implement it yourself in code. That means you would pass the Text property of the TextBox to a function you have written that implements the algorithm and then write the result to the registry. I KNOW you know how to write to the registry, right?
    Angry music? Is agrorythm a band? I can't google it.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: agrorythems

    Quote Originally Posted by mendhak
    Angry music? Is agrorythm a band? I can't google it.
    "Agro" is an Australian colloquialism, short for "aggravation" or "aggravated", and "rythem" is almost "rhythm", so together they could be the new term for some aussie heavy metal. (Sorry metal fans but some of it sounds angry to me)

    cdubb07, which algorithm are you using to encrypt your passwords? .NET has in-built support for MD5 and SHA1, so a help/MSDN search for either of those terms should give you some results. Note that these are hasing algorithms so the encryption is one-way, i.e. the hash value can never be used to re-create the original password. They are generally used to encrypt a password when it is created, then on subsequent logins the password provided is hashed using the same algorithm and compared to the stored value. That way it is safe to store the hashed password in an unsecure location, like a text file.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Posts
    307

    Re: algorithms

    how would i go about enabling md5?
    "Anybody can get angry or sad and frown but it takes a person with character to smile when times are hard."

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: algorithms

    VB Code:
    1. Dim unencryptedPassword As String 'Put actual password here.
    2. Dim unencryptedBytes As Byte() = System.Text.Encoding.Unicode.GetBytes(unencryptedPassword)
    3. Dim md5Encrypter As New System.Security.Cryptography.MD5CryptoServiceProvider
    4. Dim encryptedBytes As Byte() = md5Encrypter.ComputeHash(unencryptedBytes)
    5. Dim encryptedPassword As String = System.Text.Encoding.Unicode.GetString(encryptedBytes)
    Note that I've never done that before myself. I just looked it up in the help and used a bit of deduction.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Click Here to Expand Forum to Full Width