Here you can find the source of digest(final @Nullable String[] tokens, @Nullable final Date[] dates)
private static byte[] digest(final @Nullable String[] tokens, @Nullable final Date[] dates) throws IOException
//package com.java2s; /*/* w ww.j a v a 2s. c o m*/ * Copyright 2013 Institute for Molecular Imaging Instrumentation (I3M) * * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by * the European Commission - subsequent versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: * * http://ec.europa.eu/idabc/eupl * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the Licence for the specific language governing permissions and * limitations under the Licence. * * This product combines work with different licenses. See the "NOTICE" text * file for details on the various modules and licenses. * The "NOTICE" text file is part of the distribution. Any derivative works * that you distribute must include a readable copy of the "NOTICE" text file. */ import java.io.IOException; import java.security.MessageDigest; import java.util.Date; import javax.annotation.Nullable; public class Main { private static byte[] digest(final @Nullable String[] tokens, @Nullable final Date[] dates) throws IOException { try { String mixName = ""; if (tokens != null) { for (final String token : tokens) { mixName += (token != null ? token.trim() : ""); } } if (dates != null) { for (final Date date : dates) { mixName += (date != null ? Long.toString(date.getTime()) : ""); } } // compute digest final byte[] bytesOfMixName = mixName.getBytes("UTF-8"); final MessageDigest md = MessageDigest.getInstance("SHA"); return md.digest(bytesOfMixName); } catch (Exception e) { throw new IOException("Digest computation has failed", e); } } }