-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample06PrivateData.java
More file actions
25 lines (22 loc) · 981 Bytes
/
Example06PrivateData.java
File metadata and controls
25 lines (22 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import com.autonomi.antd.AntdClient;
import com.autonomi.antd.models.PutResult;
/**
* Example 06 — Store and retrieve private (encrypted) data.
*/
public class Example06PrivateData {
public static void main(String[] args) {
try (var client = new AntdClient()) {
// Store private data (encrypted by the daemon)
byte[] secret = "sensitive enterprise data".getBytes();
PutResult result = client.dataPutPrivate(secret);
System.out.println("Data map: " + result.address());
System.out.println("Cost: " + result.cost() + " atto");
// Retrieve private data (decrypted by the daemon)
byte[] retrieved = client.dataGetPrivate(result.address());
System.out.println("Retrieved: " + new String(retrieved));
// Estimate cost
String cost = client.dataCost(secret);
System.out.println("Estimated cost: " + cost + " atto");
}
}
}