+++ /dev/null
-/** @file\r
- \r
- The file is used to caculate file MD5 value.\r
- \r
- Copyright (c) 2006, Intel Corporation\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
- \r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
- \r
- **/\r
-package org.tianocore.frameworkwizard.far;\r
-\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.security.MessageDigest;\r
-\r
-public class FarMd5 {\r
-\r
- static public String md5(File file) throws Exception {\r
- byte[] buffer = new byte[(int) file.length()];\r
- FileInputStream fInput = new FileInputStream(file);\r
- fInput.read(buffer);\r
- fInput.close();\r
- return md5(buffer);\r
-\r
- }\r
-\r
- static public String md5(byte[] buffer) throws Exception {\r
- MessageDigest md = MessageDigest.getInstance("MD5");\r
- byte[] md5 = md.digest(buffer);\r
- return new String(String.format("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", md5[0], md5[1], md5[2], md5[3], md5[4],\r
- md5[5], md5[6], md5[7], md5[8], md5[9], md5[10], md5[11], md5[12], md5[13],\r
- md5[14], md5[15]));\r
-\r
- }\r
-}\r