Java tutorial
//package com.java2s; import java.nio.ByteBuffer; import java.util.Random; public class Main { public static byte[] getDHdataWithHash(byte[] hash, byte[] data) { int ost = (data.length + 20) % 16 > 0 ? 16 : 0; int size = ((20 + data.length) / 16) * 16 + ost; ByteBuffer buffer = ByteBuffer.allocate(size); buffer.put(hash); buffer.put(data); byte[] rand = new byte[size - hash.length - data.length]; new Random().nextBytes(rand); buffer.put(rand); return buffer.array(); } }