dotenvx-java
Dotenvx Java SDK - decrypt your .env and properties files, encrypt JSON fields etc.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Dotenvx Java SDK - decrypt your .env and properties files, encrypt JSON fields etc.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | dotenvx-java |
| description | Dotenvx Java SDK - decrypt your .env and properties files, encrypt JSON fields etc. |
Add the following dependency to your pom.xml:
<dependency>
<groupId>org.mvnsearch</groupId>
<artifactId>dotenvx-java</artifactId>
<version>0.2.4</version>
</dependency>
And use Dotenvx.load() to .env file in your Java application:
import io.github.cdimascio.dotenv.Dotenv;
import io.github.cdimascio.dotenv.Dotenvx;
Dotenv dotenv = Dotenvx.load();
final String hello = dotenv.get("HELLO");
Tips: you can use Dotenvx.configure() to customize the loading of the .env file and private key.
If you want to use a properties file, please use DotenvxPropertiesBuilder, example:
@Test
public void testLoadProperties() {
final Properties properties = new DotenvxPropertiesBuilder().filename("classpath:application.properties").load();
System.out.println(properties.get("hello"));
}
dotenvx-java loads private key from the following sources in order:
$HOME/.dotenvx/.env.keys.jsonDOTENV_PRIVATE_KEY environment variable.env.keys file in working directory$HOME/.env.keys fileYou can integrate Jackson with Dotenvx to protect some sensitive fields, such as SSN, email or phone number.
ObjectMapper getDotenvxObjectMapper() {
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(new DotenvxGlobalJsonSerializer(publicKey));
return JsonMapper.builder().addModules(simpleModule).build();
}
@Test
public void testJsonSerialize() throws IOException {
Map<String, String> info = new HashMap<>();
info.put("email", "private:demo@example.com");
info.put("nick", "Jackie");
final String jsonText = objectMapper.writeValueAsString(info);
System.out.println(jsonText);
}
If a text value prefixed with private:, and the value will be encrypted.