diff --git a/docs/sdks/languages/java.mdx b/docs/sdks/languages/java.mdx index 7c3ec55996..36c339c9bc 100644 --- a/docs/sdks/languages/java.mdx +++ b/docs/sdks/languages/java.mdx @@ -121,7 +121,7 @@ SecretElement[] secrets = client.listSecrets(options); Retrieve all secrets within the Infisical project and environment that client is connected to -### Methods +#### Methods @@ -165,7 +165,7 @@ Retrieve a secret from Infisical. By default, `getSecret()` fetches and returns a shared secret. -### Methods +#### Methods @@ -203,7 +203,7 @@ CreateSecretResponseSecret newSecret = client.createSecret(createOptions); Create a new secret in Infisical. -### Methods +#### Methods @@ -245,7 +245,7 @@ UpdateSecretResponseSecret updatedSecret = client.updateSecret(options); Update an existing secret in Infisical. -### Methods +#### Methods @@ -286,7 +286,7 @@ DeleteSecretResponseSecret deletedSecret = client.deleteSecret(options); Delete a secret in Infisical. -### Methods +#### Methods @@ -307,3 +307,76 @@ Delete a secret in Infisical. + +## Cryptography + +### Create a symmetric key + +Create a base64-encoded, 256-bit symmetric key to be used for encryption/decryption. + +```java +String key = client.createSymmetricKey(); +``` + +#### Returns (string) +`key` (string): A base64-encoded, 256-bit symmetric key, that can be used for encryption/decryption purposes. + +### Encrypt symmetric +```java +EncryptSymmetricOptions options = new EncryptSymmetricOptions(); +options.setKey(key); +options.setPlaintext("Infisical is awesome!"); + +EncryptSymmetricResponse encryptedData = client.encryptSymmetric(options); +``` + +#### Methods + + + + + The plaintext you want to encrypt. + + + The symmetric key to use for encryption. + + + + +#### Returns (object) +`tag (getTag())` (string): A base64-encoded, 128-bit authentication tag. +`iv (getIv())` (string): A base64-encoded, 96-bit initialization vector. +`ciphertext (getCipherText())` (string): A base64-encoded, encrypted ciphertext. + + +### Decrypt symmetric +```java +DecryptSymmetricOptions decryptOptions = new DecryptSymmetricOptions(); +decryptOptions.setKey(key); +decryptOptions.setCiphertext(encryptedData.getCiphertext()); +decryptOptions.setIv(encryptedData.getIv()); +decryptOptions.setTag(encryptedData.getTag()); + +String decryptedString = client.decryptSymmetric(decryptOptions); +``` + +#### Methods + + + + The ciphertext you want to decrypt. + + + The symmetric key to use for encryption. + + + The initialization vector to use for decryption. + + + The authentication tag to use for decryption. + + + + +#### Returns (string) +`Plaintext` (string): The decrypted plaintext. \ No newline at end of file diff --git a/docs/sdks/languages/node.mdx b/docs/sdks/languages/node.mdx index 9179e2f9d5..3e6b0cae96 100644 --- a/docs/sdks/languages/node.mdx +++ b/docs/sdks/languages/node.mdx @@ -84,12 +84,12 @@ Import the SDK and create a client instance with your [Machine Identity](/docume clientSecret: "YOUR_CLIENT_SECRET", logLevel: LogLevel.Error }); - ```` + ``` -### Parameters +#### Parameters @@ -138,7 +138,7 @@ const secrets = await client.listSecrets({ Retrieve all secrets within the Infisical project and environment that client is connected to -### Parameters +#### Parameters @@ -180,7 +180,7 @@ Retrieve a secret from Infisical. By default, `getSecret()` fetches and returns a shared secret. -### Parameters +#### Parameters @@ -255,7 +255,7 @@ const updatedApiKey = await client.updateSecret({ Update an existing secret in Infisical. -### Parameters +#### Parameters @@ -315,3 +315,73 @@ Delete a secret in Infisical. + +## Cryptography + +### Create a symmetric key + +Create a base64-encoded, 256-bit symmetric key to be used for encryption/decryption. + +```js +const key = client.createSymmetricKey(); +``` + +#### Returns (string) +`key` (string): A base64-encoded, 256-bit symmetric key, that can be used for encryption/decryption purposes. + +### Encrypt symmetric +```js +const { iv, tag, ciphertext } = await client.encryptSymmetric({ + key: key, + plaintext: "Infisical is awesome!", +}) +``` + +#### Parameters + + + + + The plaintext you want to encrypt. + + + The symmetric key to use for encryption. + + + + +#### Returns (object) +`tag` (string): A base64-encoded, 128-bit authentication tag. +`iv` (string): A base64-encoded, 96-bit initialization vector. +`ciphertext` (string): A base64-encoded, encrypted ciphertext. + +### Decrypt symmetric +```js +const decryptedString = await client.decryptSymmetric({ + key: key, + iv: iv, + tag: tag, + ciphertext: ciphertext, +}); +``` + +#### Parameters + + + + The ciphertext you want to decrypt. + + + The symmetric key to use for encryption. + + + The initialization vector to use for decryption. + + + The authentication tag to use for decryption. + + + + +#### Returns (string) +`plaintext` (string): The decrypted plaintext. diff --git a/docs/sdks/languages/python.mdx b/docs/sdks/languages/python.mdx index 8420e6e77c..320dcb49cd 100644 --- a/docs/sdks/languages/python.mdx +++ b/docs/sdks/languages/python.mdx @@ -60,7 +60,7 @@ client = InfisicalClient(ClientSettings( )) ``` -### Parameters +#### Parameters @@ -110,7 +110,7 @@ client.listSecrets(options=ListSecretsOptions( Retrieve all secrets within the Infisical project and environment that client is connected to -### Parameters +#### Parameters @@ -149,7 +149,7 @@ value = secret.secret_value # get its value By default, `getSecret()` fetches and returns a shared secret. If not found, it returns a personal secret. -### Parameters +#### Parameters @@ -187,7 +187,7 @@ api_key = client.createSecret(options=CreateSecretOptions( Create a new secret in Infisical. -### Parameters +#### Parameters @@ -225,7 +225,7 @@ client.updateSecret(options=UpdateSecretOptions( Update an existing secret in Infisical. -### Parameters +#### Parameters @@ -262,7 +262,7 @@ client.deleteSecret(options=DeleteSecretOptions( Delete a secret in Infisical. -### Parameters +#### Parameters @@ -283,3 +283,101 @@ Delete a secret in Infisical. + + + + + + + + + + + + + + + + + + + + + + + +## Cryptography + +### Create a symmetric key + +Create a base64-encoded, 256-bit symmetric key to be used for encryption/decryption. + +```py +key = client.createSymmetricKey() +``` + +#### Returns (string) +`key` (string): A base64-encoded, 256-bit symmetric key, that can be used for encryption/decryption purposes. + +### Encrypt symmetric +```py +encryptOptions = EncryptSymmetricOptions( + key=key, + plaintext="Infisical is awesome!" +) + +encryptedData = client.encryptSymmetric(encryptOptions) +``` + +#### Parameters + + + + + The plaintext you want to encrypt. + + + The symmetric key to use for encryption. + + + + +#### Returns (object) +`tag` (string): A base64-encoded, 128-bit authentication tag. +`iv` (string): A base64-encoded, 96-bit initialization vector. +`ciphertext` (string): A base64-encoded, encrypted ciphertext. + +### Decrypt symmetric +```py +decryptOptions = DecryptSymmetricOptions( + ciphertext=encryptedData.ciphertext, + iv=encryptedData.iv, + tag=encryptedData.tag, + key=key +) + +decryptedString = client.decryptSymmetric(decryptOptions) + + +``` + +#### Parameters + + + + The ciphertext you want to decrypt. + + + The symmetric key to use for encryption. + + + The initialization vector to use for decryption. + + + The authentication tag to use for decryption. + + + + +#### Returns (string) +`plaintext` (string): The decrypted plaintext.