Skip to content

Simple Example

Examples

Here is a simple example of how to use sosecrets:

Creating a secret value

from sosecrets import Secret

# Create a secret value
secret_value = Secret("my secret value")

Using the secret value

# Use the secret value while keeping it encapsulated
result = secret_value.apply(len)
print(result.expose_secret())  # Output: 14

Retrieving the secret value

# Get the value of the secret
value = secret_value.expose_secret()
print(value)  # Output: "my secret value"