Native library v2: rebuild this integration against libzupt 2.0.0. Generate new v2 keys; old ciphertext requires explicit migration. Use the library's
zupt_free()for C allocations. Platform/binding coverage is determined by actual CI runs, not by the presence of these examples.
This directory contains Java examples using JNI bindings for the libzupt library.
- Java 11 or higher
- C++ compiler (g++ with C++17 support)
- libzupt built with static library
mkdir build
cd build
cmake .. -DLIBZUPT_ROOT=../../
export LD_LIBRARY_PATH=/dados/fontes/libzupt/examples_java/build
javac -d classes ../src/com/libzupt/*.java
java -cp classes com.libzupt.ExampleBasic
java -cp classes com.libzupt.ExampleKeygen
java -cp classes com.libzupt.ExampleFile
java -cp classes com.libzupt.ExampleRandom
java -cp classes com.libzupt.ExampleSecureBuffercd examples_java
./build.shThe build script will:
- Build libzupt if needed
- Compile the JNI shared library
- Place
libzupt.soin the current directory
# Set library path
export LD_LIBRARY_PATH=".:$LD_LIBRARY_PATH"
# Compile Java classes
javac -cp . com/libzupt/*.java com/libzupt/ExampleBasic.java
# Run example
java -cp . -Djava.library.path=. com.libzupt.ExampleBasic- ExampleBasic.java - Basic encryption/decryption
- ExampleKeygen.java - Key generation and management
- ExampleFile.java - File encryption/decryption
- ExampleSecureBuffer.java - SecureBuffer usage
- ExampleRandom.java - Random bytes and hashing
generateKeyPair()- Generate a new key pairloadKeyPair(filename)- Load a key pair from fileloadPublicKey(filename)- Load public key from fileexportPublicKey(privFile, pubFile)- Export public keysaveKeyPair(keyPair, filename)- Save key pair to file
encryptMemory(data)- Encrypt data in memoryencryptMemorySecure(buffer)- Encrypt SecureBufferencryptFile(filename)- Encrypt a file
decryptMemory(ciphertext, header)- Decrypt in memorydecryptMemorySecure(ciphertext, header)- Decrypt to SecureBufferdecryptFile(filename, header)- Decrypt a file
randomBytes(size)- Generate random bytessha256(data)- Compute SHA-256 hashsha3512(data)- Compute SHA3-512 hash
SecureBuffer(size)- Create buffer of sizeSecureBuffer(data)- Create from byte arraysize()- Get buffer sizetoBytes()- Get buffer contenttoString()- Get string representationzeroize()- Securely wipe bufferclose()- Auto-wipe buffer
MIT