# Redacted

The Redacted module provides functionality for handling sensitive information securely within your application.
By using the `Redacted` data type, you can ensure that sensitive values are not accidentally exposed in logs or error messages.

## make

The `Redacted.make` function creates a `Redacted<A>` instance from a given value `A`, ensuring the content is securely hidden.

**Example** (Hiding Sensitive Information from Logs)

Using `Redacted.make` helps prevent sensitive information, such as API keys, from being accidentally exposed in logs or error messages.

```ts
import { Redacted, Effect } from "effect"

// Create a redacted API key
const API_KEY = Redacted.make("1234567890")

console.log(API_KEY)
// Output: <redacted>

console.log(String(API_KEY))
String(API_KEY) // => "<redacted>"

Effect.runSync(Effect.log(API_KEY))
/*
Output:
[...] INFO (#...): <redacted>
*/
```

## value

The `Redacted.value` function retrieves the original value from a `Redacted` instance. Use this function carefully, as it exposes the sensitive data, potentially making it visible in logs or accessible in unintended ways.

**Example** (Accessing the Underlying Sensitive Value)

```ts
import { Redacted } from "effect"

const API_KEY = Redacted.make("1234567890")

// Expose the redacted value
console.log(Redacted.value(API_KEY))
Redacted.value(API_KEY) // => "1234567890"
```

## unsafeWipe

The `Redacted.wipeUnsafe` function erases the underlying value of a `Redacted` instance, making it inaccessible. This helps ensure that sensitive data does not remain in memory longer than needed.

**Example** (Wiping Sensitive Data from Memory)

```ts
import { Redacted } from "effect"

const API_KEY = Redacted.make("1234567890")

console.log(Redacted.value(API_KEY))
// Output: "1234567890"

Redacted.wipeUnsafe(API_KEY)

console.log(Redacted.value(API_KEY))
/*
throws:
Error: Unable to get redacted value
*/
```

## getEquivalence

The `Redacted.makeEquivalence` function generates an [Equivalence](/docs/v4/behaviour/equivalence/) for `Redacted<A>` values using an Equivalence for the underlying values of type `A`. This allows you to compare `Redacted` values securely without revealing their content.

**Example** (Comparing Redacted Values)

```ts
import { Redacted, Equivalence } from "effect"

const API_KEY1 = Redacted.make("1234567890")
const API_KEY2 = Redacted.make("1-34567890")
const API_KEY3 = Redacted.make("1234567890")

const equivalence = Redacted.makeEquivalence(Equivalence.String)

console.log(equivalence(API_KEY1, API_KEY2))
equivalence(API_KEY1, API_KEY2) // => false

console.log(equivalence(API_KEY1, API_KEY3))
equivalence(API_KEY1, API_KEY3) // => true
```
