Java tutorial
//package com.java2s; import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.digest.DigestUtils; public class Main { public static String multiShaHex(byte[] data) { return new String(Hex.encodeHex(multiSha(data))); } public static byte[] multiSha(byte[] data) { byte[] res = DigestUtils.sha1(data); int headLength = res.length / 2; byte[] head = new byte[headLength]; if (res.length > headLength) { byte[] tail = new byte[res.length - headLength]; System.arraycopy(res, 0, head, 0, headLength); System.arraycopy(res, headLength, tail, 0, tail.length); head = DigestUtils.sha1(head); tail = DigestUtils.sha1(tail); res = new byte[head.length + tail.length]; System.arraycopy(head, 0, res, 0, head.length); System.arraycopy(tail, 0, res, head.length, tail.length); } res = DigestUtils.sha1(res); return res; } }