Build Status

Hive2Hive is an open-source library, written in Java, for secure, distributed, P2P-based file synchronization and sharing. It is built on top of TomP2P, an advanced, high-performance DHT for multi-key-value pairs. The Hive2Hive project is licensed under the MIT License and any contribution is welcome.

Problems of common sync and sharing services

Although many well-known synchronization and sharing services exist, most of them exhibit the following drawbacks:

Hive2Hive is the solution!

The Hive2Hive library addresses these issues by providing a free and open-sourced, distributed and scalable solution that focuses on maximum security and privacy of both users and data. Aside of this, it supports the whole feature set known from similar centralized approaches, such as Dropbox, OneDrive or Google Drive, and adds functionality for file versioning and conflict management. All packed in a clean, simple API.

There are many simple ways to improve this experience even more. Start to contribute now!

Check our GitHub Wiki to learn more about How To Use and How It Works.

Are you looking for a demo application?

Table of Contents

API Demonstration
Features & Advantages

API Demonstration

The Hive2Hive library provides a simple API that is straightforward to use. (View Source) A short demonstration of the API and its basic usage are given here.

Network Management

Creating a P2P Network

Configuring and setting up a new P2P network is very easy. Just specify the configurations and setup an initial node.

  1. The NetworkConfiguration and FileConfiguration factory classes may help to specify your configurations.
  2. Create an initial peer node and connect it.
INetworkConfiguration netConfig = NetworkConfiguration.create("first");
IFileConfiguration fileConfig = FileConfiguration.createDefault();

IH2HNode peerNode = H2HNode.createNode(netConfig, fileConfig);

Joining an Existing P2P Network

You may want to add other peer nodes to the created network. Any node can join by bootstrapping to another node that is already part of the network.

  1. Specify the network configuration for the joining node (i.e., provide the bootstrap address of another node).
  2. Create the new node and connect it. It will bootstrap according to its network configuration.
INetworkConfiguration netConfig2 = NetworkConfiguration.create("second", InetAddress.getByName(""));
IH2HNode peerNode2 = H2HNode.createNode(netConfig2, fileConfig);

User Management

Once a peer node is connected to a network, users can interact with it. For this, each node provides a user management interface.

  1. The user has to provide her credentials.
  2. Login the user to the network. If it's the first login, she has to register herself, one-time.
  3. Then, the user can interact with the network (i.e., file management is enabled).
IUserManager userManager = peerNode.getUserManager();

UserCredentials credentials = new UserCredentials("userId", "password", "pin");
Path rootDirectory = Paths.get("sample/path/to/rootDirectory");

if (!userManager.isRegistered(credentials.getUserId())) {
userManager.login(credentials, rootDirectory).await();

File Management

As soon as a user is logged in to the network, her files are automatically synchronized with the current node. Many further file operations are available. For this, each node provides a file management interface.

IFileManager fileManager = peerNode.getFileManager();

File folder = new File("folderpath");
File file = new File(folder, "filepath");



fileManager.share(folder, "other-userId", PermissionType.WRITE);

IVersionSelector versionSelector = new IVersionSelector() {
    public IFileVersion selectVersion(List<IFileVersion> availableVersions) {
        return availableVersions.get(0);
fileManager.recover(file, versionSelector);

fileManager.move(folder, new File("other-folder"));


File Watchdog

In order to keep track of changes in the local file system, a file observer is needed. This observer notifies its attached listeners about all file system events. Either use the provided H2HFileObserver and H2HFileObserverListener or implement your own observer adhering to the IFileObserver and IFileObserverListener interfaces.
The H2HFileObserverListener automatically synchronizes the Hive2Hive root folder with the network.

IFileObserverListener listener = new H2HFileObserverListener(fileManager);

IFileObserver observer = new H2HFileObserver(rootDirectory.toFile());

Features & Advantages

Hive2Hive offers the same basic functionality known from popular synchronization services (e.g., Dropbox).
On top of that, Hive2Hive provides additional features such as security and versioning.

Using the Hive2Hive library is very simple and has several advantages:

* Try our console-based org.hive2hive.client by just executing the library .jar.

And there is even more to come:


There are three easy ways to get and include the Hive2Hive library into your project.

If you just want to use the library, either refer to option 1 or 2.
If you want to contribute to the project, please refer to option 3.



The library is intended to be improved and extended so that we all profit from its capabilities. Unlike many other “secure” services, Hive2Hive discloses its implementation and is open for any sort of contribution and constructive criticism.

We believe that everyone can contribute to make Hive2Hive even better!

There are several things - from simple to complex - you can do to help:

Also, if you are a professional cryptographer with interest in this project, any feedback on the project is very welcome!