Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Encryption

Encryption

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasealgorithmssecurityquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KreativeKai
    wrote on last edited by
    #1

    I've spent most of the afternoon searching and looking at all kinds of encryption classes. I know that encryption can be a very detailed topic and it should be, but I'm just looking for something simple. I want to take a text string 'The cat ate the mouse' and convert it to a SHA2 hex string that I can then store into a database. Is there code to simply just do this? I've downloaded all kind of samples which have classes involved that are several pages of code. It's got to be simpler than this? Or of course then it might not be secure if it is too simple to encrypt / decrypt. Any suggestions on something simple would be helpful? :confused:

    Lost in the vast sea of .NET

    A G 2 Replies Last reply
    0
    • K KreativeKai

      I've spent most of the afternoon searching and looking at all kinds of encryption classes. I know that encryption can be a very detailed topic and it should be, but I'm just looking for something simple. I want to take a text string 'The cat ate the mouse' and convert it to a SHA2 hex string that I can then store into a database. Is there code to simply just do this? I've downloaded all kind of samples which have classes involved that are several pages of code. It's got to be simpler than this? Or of course then it might not be secure if it is too simple to encrypt / decrypt. Any suggestions on something simple would be helpful? :confused:

      Lost in the vast sea of .NET

      A Offline
      A Offline
      AlexeiXX3
      wrote on last edited by
      #2

      You can use a function like the following:

      Public Shared Function EncryptSHA512(ByVal strAs String) As String
      Dim Bytes() As Byte
      Dim Encoder As New System.Text.UTF8Encoding
      Dim SHA512 As New System.Security.Cryptography.SHA512Managed
      Dim SHA512String As String

          Bytes = Encoder.GetBytes(str)
          Bytes = SHA512.ComputeHash(Bytes)
          SHA512String = Convert.ToBase64String(Bytes)
          Return SHA512String
      End Function
      

      Alexei Rodriguez

      K 1 Reply Last reply
      0
      • K KreativeKai

        I've spent most of the afternoon searching and looking at all kinds of encryption classes. I know that encryption can be a very detailed topic and it should be, but I'm just looking for something simple. I want to take a text string 'The cat ate the mouse' and convert it to a SHA2 hex string that I can then store into a database. Is there code to simply just do this? I've downloaded all kind of samples which have classes involved that are several pages of code. It's got to be simpler than this? Or of course then it might not be secure if it is too simple to encrypt / decrypt. Any suggestions on something simple would be helpful? :confused:

        Lost in the vast sea of .NET

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        SHA is not an encryption algorithm, it's a hashing algorithm.

        Despite everything, the person most likely to be fooling you next is yourself.

        1 Reply Last reply
        0
        • A AlexeiXX3

          You can use a function like the following:

          Public Shared Function EncryptSHA512(ByVal strAs String) As String
          Dim Bytes() As Byte
          Dim Encoder As New System.Text.UTF8Encoding
          Dim SHA512 As New System.Security.Cryptography.SHA512Managed
          Dim SHA512String As String

              Bytes = Encoder.GetBytes(str)
              Bytes = SHA512.ComputeHash(Bytes)
              SHA512String = Convert.ToBase64String(Bytes)
              Return SHA512String
          End Function
          

          Alexei Rodriguez

          K Offline
          K Offline
          KreativeKai
          wrote on last edited by
          #4

          This function is exactly what I was looking for. Currently I'm writing a test application that simply has a form and two buttons, encrypt and decrypt. The encrypt works great with this function, but when I try to write the decrypt function everything works, but I can't find logic to reverse the ComputeHash code? Below is what I have: Public Shared Function DecryptSHA512(ByVal str As String) As String Dim Bytes() As Byte Dim Encoder As New System.Text.UTF8Encoding Dim SHA512 As New System.Security.Cryptography.SHA512Managed Dim RegularString As String Bytes = Convert.FromBase64String(str) 'Bytes = SHA512.??(Bytes) 'Can't find reverse logic RegularString = Encoder.GetString(Bytes) Return RegularString End Function Thanks again for the code you have given and any suggestions on the decrypt logic is welcome :)

          Lost in the vast sea of .NET

          A 1 Reply Last reply
          0
          • K KreativeKai

            This function is exactly what I was looking for. Currently I'm writing a test application that simply has a form and two buttons, encrypt and decrypt. The encrypt works great with this function, but when I try to write the decrypt function everything works, but I can't find logic to reverse the ComputeHash code? Below is what I have: Public Shared Function DecryptSHA512(ByVal str As String) As String Dim Bytes() As Byte Dim Encoder As New System.Text.UTF8Encoding Dim SHA512 As New System.Security.Cryptography.SHA512Managed Dim RegularString As String Bytes = Convert.FromBase64String(str) 'Bytes = SHA512.??(Bytes) 'Can't find reverse logic RegularString = Encoder.GetString(Bytes) Return RegularString End Function Thanks again for the code you have given and any suggestions on the decrypt logic is welcome :)

            Lost in the vast sea of .NET

            A Offline
            A Offline
            AlexeiXX3
            wrote on last edited by
            #5

            This can not be decrypted Its a one way hashing algorithm

            Alexei Rodriguez

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups