https://github.com/rapid7/community-id-java
A Java implementation of the Community ID flow hashing standard
https://github.com/rapid7/community-id-java
Last synced: over 1 year ago
JSON representation
A Java implementation of the Community ID flow hashing standard
- Host: GitHub
- URL: https://github.com/rapid7/community-id-java
- Owner: rapid7
- License: apache-2.0
- Created: 2019-12-16T17:42:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-04-09T15:57:04.000Z (over 1 year ago)
- Last Synced: 2025-04-13T00:44:06.166Z (over 1 year ago)
- Language: Java
- Size: 53.7 KB
- Stars: 2
- Watchers: 41
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING
- License: LICENSE.txt
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
community-id-java
=================
This package provides a Java 8 implementation of the open
[Community ID](https://github.com/corelight/community-id-spec)
flow hashing standard.
This library supports IPV4 and IPV6 addresses and TCP, UDP, and STCP network protocols. It does not support ICMP protocols.
### How it works
The Community ID Generator creates a Community ID string by taking in a protocol, source IP address, source port, destination address, and destination port. It creates two IpPortPair objects and sorts them in a deterministic order. It then packs the necessary bytes in NBO order, and produces a 20-byte SHA1 digest. Then, base64 encodes it or turns it into a hexadecimal string depending on configuration. It appends the value to "1:" for version 1.
The Community ID generator is configurable to take in a seed value to be packed and encoded as well as a boolean for base64 encoding. Only the first two bytes of the seed value will be used in the Community ID.
### Getting community-id-java
To add community-id-java to your Maven project, use the following:
```xml
com.rapid7.communityid
community-id-java
2.0.0
```
### Example of creating a Community ID:
```java
CommunityIdGenerator generator = new CommunityIdGenerator();
//The default constructor will set seed to 0 and base64 to true
String result = generator.generateCommunityId(Protocol.UDP,
InetAddress.getByName("192.168.1.52"), 54585, InetAddress.getByName("8.8.8.8"), 53);
```
result will look like:
```
"1:Q9We8WO3piVF8yEQBNJF4uiSVrI=".
```