locked
Getting a file MD5 checksum RRS feed

  • Question

  • How do I get the MD5 checksum of a file using J#?
    I know about the "import System.Security.Cryptography.*;" and how to create the MD5 object but I cant seem to get it to work.

    Thanks for any help.
    Saturday, September 2, 2006 8:48 AM

Answers

  • You can create MessageDigest object for MD5 using the following code.



    MessageDigest md5 = MessageDigest.getInstance("MD5");

     

     

    Saturday, September 2, 2006 10:19 PM
  • You have to refer Java API. 
    See
    http://java.sun.com/j2se/1.4.2/docs/api/java/security/MessageDigest.html .
    If you want to use .NET function, use the following code.

    new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(inputBytes)

     
    Above returns MD5. Preparing inputBytes is your work.
     
    Wednesday, September 6, 2006 2:45 PM

All replies

  • You can create MessageDigest object for MD5 using the following code.



    MessageDigest md5 = MessageDigest.getInstance("MD5");

     

     

    Saturday, September 2, 2006 10:19 PM
  • Hello!

    Cant get that to work, what do I have to import?
    I want to be able to load a file using BufferedReader input = new BufferedReader(new FileReader(File test));

    then I want to load that file and get the MD5 checksum.
    Tuesday, September 5, 2006 1:41 PM
  • You have to refer Java API. 
    See
    http://java.sun.com/j2se/1.4.2/docs/api/java/security/MessageDigest.html .
    If you want to use .NET function, use the following code.

    new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(inputBytes)

     
    Above returns MD5. Preparing inputBytes is your work.
     
    Wednesday, September 6, 2006 2:45 PM
  • I'm using JScript.net for my current project. Can you tell me that how can I calculate MD5 checksum of a file or a string in JScript.net. I've got big headache about this :P
    Tuesday, January 30, 2007 4:23 AM
  • Hi,

    In Jscript .net too you can refer any of the .net dll and consume the classes in it.

    For this particualr issue...

    1. import System.Secutiry in your .js file.

    2. Use the classes as per your need.

    3. While compiling pass System.Security.dll to compiler using /r: switch.

    Hope it helps.

    Thanks.

    Tuesday, January 30, 2007 6:51 AM