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. C#
  4. how to use a key in md5 algorithm in c#

how to use a key in md5 algorithm in c#

Scheduled Pinned Locked Moved C#
csharpalgorithmssecuritytutorialquestion
8 Posts 5 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.
  • R Offline
    R Offline
    rincy sivan
    wrote on last edited by
    #1

    hi please tell me how to use a key in md5 encryption algorithm and how can I decript using MD5

    L OriginalGriffO A 4 Replies Last reply
    0
    • R rincy sivan

      hi please tell me how to use a key in md5 encryption algorithm and how can I decript using MD5

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You can't; MD5 is a one-way hash, not an encryption algorithm. There's no way to decrypt it.

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

      OriginalGriffO 1 Reply Last reply
      0
      • L Lost User

        You can't; MD5 is a one-way hash, not an encryption algorithm. There's no way to decrypt it.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        Down vote countered.

        Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • R rincy sivan

          hi please tell me how to use a key in md5 encryption algorithm and how can I decript using MD5

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          It doesn't matter how often you down vote people, that won't change the facts: MD5 is not an encryption algorithm, and the output cannot be decrypted back to regenerate exactly what was input. This is because it is a Hashing algorithm, which "throws away" information when it generate the MD5. It effectively works klice the more primitive SUM for generating a checksum:

          byte sum = 0;
          foreach (byte b in myData)
          {
          sum += b;
          }

          Although this generates a "unique" code which can verify that the myData is unchanged (to a limited extent) you cannot take the single byte output and regenerate the exact input from just that. MD5 (and SHA) work the same way: they use and discard information to get a value that can give you a very high confidence that the data is unchanged, but it can't be "decrypted" back to the original input. Otherwise, we would just store the MD5 of a video file and transfer just 128 bits instead of 700Mb and just "decrypt" it at the destination...

          Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          M 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            It doesn't matter how often you down vote people, that won't change the facts: MD5 is not an encryption algorithm, and the output cannot be decrypted back to regenerate exactly what was input. This is because it is a Hashing algorithm, which "throws away" information when it generate the MD5. It effectively works klice the more primitive SUM for generating a checksum:

            byte sum = 0;
            foreach (byte b in myData)
            {
            sum += b;
            }

            Although this generates a "unique" code which can verify that the myData is unchanged (to a limited extent) you cannot take the single byte output and regenerate the exact input from just that. MD5 (and SHA) work the same way: they use and discard information to get a value that can give you a very high confidence that the data is unchanged, but it can't be "decrypted" back to the original input. Otherwise, we would just store the MD5 of a video file and transfer just 128 bits instead of 700Mb and just "decrypt" it at the destination...

            Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

            M Offline
            M Offline
            Marco Bertschi
            wrote on last edited by
            #5

            What you are stating is not true - You can revert MD5 if you don't exceed the maximum of 1 byte :laugh: :laugh:

            The scariest moment is always just before the Start - Stephen King
            Die Frauen warten auf die Liebe, und die Männer warten auf die Frauen - Wolf Wondratschek

            OriginalGriffO 1 Reply Last reply
            0
            • R rincy sivan

              hi please tell me how to use a key in md5 encryption algorithm and how can I decript using MD5

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              While it seems unlikely that you actually meant to ask "how can I generate a pre-image of an MD5 hash", that would be a much more interesting question, so I'll pretend you asked it. In general, that's still "very hard". That is, given a random MD5 hash x, it's not (yet) feasible to compute a string that would hash to x (though there is an 2123.4 attack, which is better than brute force). By the way, there is obviously an unlimited number of strings that would have the same hash, because there's an infinite number of different strings and only a finite number of MD5 hashes. So in general it's not possible to get the actual original string, but you may find a string that has the same hash, and for short strings there's a very good probability that you would have found the original. By contrast, generating two strings that have the same MD5 hash is efficiently doable[^] and highly realistic. If you know something about the key, for example that it's an 8-letter alpha-numeric string, a brute force attack is often very feasible - for this example, it would take several hours on a good GPU. (26+26+10)8 / 10GH/s[^] = about 6 hours, and you could buy a better GPU, or several. MD5-ed passwords hashes can also be easy, it depends. On the one hand, it's obviously possible to make a long random password, and you won't crack it. But on the other hand, most passwords used in real life are not like that. See for example this article[^] about some of the subtleties of passwords.

              1 Reply Last reply
              0
              • M Marco Bertschi

                What you are stating is not true - You can revert MD5 if you don't exceed the maximum of 1 byte :laugh: :laugh:

                The scariest moment is always just before the Start - Stephen King
                Die Frauen warten auf die Liebe, und die Männer warten auf die Frauen - Wolf Wondratschek

                OriginalGriffO Offline
                OriginalGriffO Offline
                OriginalGriff
                wrote on last edited by
                #7

                Hmm. Yes, that would work. I must immediately encrypt each byte of my files into MD5... ...hang on, why did they all get 32 times larger? :laugh:

                Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                1 Reply Last reply
                0
                • R rincy sivan

                  hi please tell me how to use a key in md5 encryption algorithm and how can I decript using MD5

                  A Offline
                  A Offline
                  AmitGajjar
                  wrote on last edited by
                  #8

                  First of all you need to understand difference between Hashing and Encryption. Based on your requirement you need to choose correct method to secure your data. Check this[^] thread to understand why MD5 is irreversible.

                  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