Java MD5 Check isValidMd5Hash(String md5Hash)

Here you can find the source of isValidMd5Hash(String md5Hash)

Description

Determines whether a string representation of an MD5 hash is valid.

License

Open Source License

Parameter

Parameter Description
md5Hash The hash.

Return

True or false.

Declaration

public static boolean isValidMd5Hash(String md5Hash) 

Method Source Code

//package com.java2s;
/*//  w w w  . java  2  s . c  o m
 * Autopsy Forensic Browser
 *
 * Copyright 2011 Basis Technology Corp.
 * Contact: carrier <at> sleuthkit <dot> org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    /**
     * Determines whether a string representation of an MD5 hash is valid.
     *
     * @param md5Hash The hash.
     *
     * @return True or false.
     */
    public static boolean isValidMd5Hash(String md5Hash) {
        return md5Hash.matches("^[A-Fa-f0-9]{32}$");
    }
}

Related

  1. isValidMD5(String md5)
  2. isValidMD5(String s)