Skip to content

[12.x] Add decrypt and encrypt methods to strings #10487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ Laravel includes a variety of functions for manipulating string values. Many of
[chopEnd](#method-fluent-str-chop-end)
[contains](#method-fluent-str-contains)
[containsAll](#method-fluent-str-contains-all)
[decrypt](#method-fluent-str-decrypt)
[deduplicate](#method-fluent-str-deduplicate)
[dirname](#method-fluent-str-dirname)
[encrypt](#method-fluent-str-encrypt)
[endsWith](#method-fluent-str-ends-with)
[exactly](#method-fluent-str-exactly)
[excerpt](#method-fluent-str-excerpt)
Expand Down Expand Up @@ -2140,6 +2142,21 @@ $containsAll = Str::of('This is my name')->containsAll(['MY', 'NAME'], ignoreCas
// true
```

<a name="method-fluent-str-decrypt"></a>
#### `decrypt` {.collection-method}

The `decrypt` method [decrypts](/docs/{{version}}/encryption) the encrypted string:

```php
use Illuminate\Support\Str;

$decrypted = $encrypted->decrypt();

// 'secret'
```

For the inverse of `decrypt`, see the [encrypt](#method-fluent-str-encrypt) method.

<a name="method-fluent-str-deduplicate"></a>
#### `deduplicate` {.collection-method}

Expand Down Expand Up @@ -2186,6 +2203,19 @@ $string = Str::of('/foo/bar/baz')->dirname(2);
// '/foo'
```

<a name="method-fluent-str-encrypt"></a>
#### `encrypt` {.collection-method}

The `encrypt` method [encrypts](/docs/{{version}}/encryption) the string:

```php
use Illuminate\Support\Str;

$encrypted = Str::of('secret')->encrypt();
```

For the inverse of `encrypt`, see the [decrypt](#method-fluent-str-decrypt) method.

<a name="method-fluent-str-ends-with"></a>
#### `endsWith` {.collection-method}

Expand Down