Skip to content

Commit ef7f9a8

Browse files
committed
README: consistent structure, cross-language examples, policy file
1 parent 217135e commit ef7f9a8

1 file changed

Lines changed: 31 additions & 21 deletions

File tree

README.md

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Data protection SDK for Java — format-preserving encryption (FF1/FF3), AES-GCM
88
<dependency>
99
<groupId>io.cyphera</groupId>
1010
<artifactId>cyphera</artifactId>
11-
<version>0.0.1-alpha.1</version>
11+
<version>0.0.1-alpha.2</version>
1212
</dependency>
1313
```
1414

@@ -18,39 +18,49 @@ Available on [Maven Central](https://central.sonatype.com/artifact/io.cyphera/cy
1818

1919
```java
2020
import io.cyphera.Cyphera;
21-
import java.util.HashMap;
22-
import java.util.Map;
2321

24-
Map<String, Object> config = new HashMap<>();
22+
// Auto-discover: checks CYPHERA_POLICY_FILE env, ./cyphera.json, /etc/cyphera/cyphera.json
23+
Cyphera c = Cyphera.load();
2524

26-
Map<String, Object> policies = new HashMap<>();
27-
Map<String, Object> ssn = new HashMap<>();
28-
ssn.put("engine", "ff1");
29-
ssn.put("key_ref", "my-key");
30-
ssn.put("tag", "T01");
31-
policies.put("ssn", ssn);
32-
config.put("policies", policies);
33-
34-
Map<String, Object> keys = new HashMap<>();
35-
Map<String, Object> key = new HashMap<>();
36-
key.put("material", "2B7E151628AED2A6ABF7158809CF4F3C");
37-
keys.put("my-key", key);
38-
config.put("keys", keys);
39-
40-
Cyphera c = Cyphera.fromMap(config);
25+
// Or load from a specific file
26+
Cyphera c = Cyphera.fromFile("./config/cyphera.json");
4127

4228
// Protect
4329
String encrypted = c.protect("123-45-6789", "ssn");
44-
// → "T01k7R-m2-9xPq" (tagged, dashes preserved)
30+
// → "T01i6J-xF-07pX" (tagged, dashes preserved)
4531

4632
// Access (tag-based, no policy name needed)
4733
String decrypted = c.access(encrypted);
4834
// → "123-45-6789"
4935
```
5036

37+
## Policy File (cyphera.json)
38+
39+
```json
40+
{
41+
"policies": {
42+
"ssn": { "engine": "ff1", "key_ref": "my-key", "tag": "T01" }
43+
},
44+
"keys": {
45+
"my-key": { "material": "2B7E151628AED2A6ABF7158809CF4F3C" }
46+
}
47+
}
48+
```
49+
50+
## Cross-Language Compatible
51+
52+
Java, Rust, and Node produce identical output for the same inputs:
53+
54+
```
55+
Input: 123-45-6789
56+
Java: T01i6J-xF-07pX
57+
Rust: T01i6J-xF-07pX
58+
Node: T01i6J-xF-07pX
59+
```
60+
5161
## Status
5262

53-
Alpha. API is unstable. Cross-language test vectors validated against Rust implementation.
63+
Alpha. API is unstable. Cross-language test vectors validated against Rust and Node implementations.
5464

5565
## License
5666

0 commit comments

Comments
 (0)