Java MD5 getMd5Script(String dstFilePath)

Here you can find the source of getMd5Script(String dstFilePath)

Description

get Md Script

License

Open Source License

Declaration

private static String getMd5Script(String dstFilePath) 

Method Source Code

//package com.java2s;
/*// w  w  w  . j a va  2 s . com
    
 Copyright (C) 2014 NTT DATA Corporation
    
 This program is free software; you can redistribute it and/or
 Modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation, version 2.
    
 This program is distributed in the hope that it will be
 useful, but WITHOUT ANY WARRANTY; without even the implied
 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.  See the GNU General Public License for more details.
    
 */

public class Main {
    private static String winReturnCode = "\n";

    private static String getMd5Script(String dstFilePath) {
        StringBuffer buffer = new StringBuffer();
        buffer.append(String.format("$filePath=\"%s\"" + winReturnCode, dstFilePath));
        buffer.append(
                "$md5=New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider" + winReturnCode);
        buffer.append(
                "$hash=[System.BitConverter]::ToString($md5.ComputeHash([System.IO.File]::ReadAllBytes($filePath)))"
                        + winReturnCode);
        buffer.append("$hash" + winReturnCode);

        return buffer.toString();
    }
}

Related

  1. getMD5ByString(String orginalString)
  2. getMD5Checksum(String path)
  3. getMd5DigestHex(final String content)
  4. getMD5Hex(byte[] digest)
  5. getMD5Prefix()
  6. inputStreamMD5(InputStream entity)
  7. isEtagAlsoAnMD5Hash(String etag)
  8. looksLikeValidMd5(String possibleMd5)
  9. md5(File f)