Skip to content

Commit dcd1372

Browse files
[12.x] Add decrypt and encrypt methods to strings (#10487)
* Add decrypt and encrypt methods to strings * formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 7560640 commit dcd1372

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

strings.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,10 @@ Laravel includes a variety of functions for manipulating string values. Many of
145145
[chopEnd](#method-fluent-str-chop-end)
146146
[contains](#method-fluent-str-contains)
147147
[containsAll](#method-fluent-str-contains-all)
148+
[decrypt](#method-fluent-str-decrypt)
148149
[deduplicate](#method-fluent-str-deduplicate)
149150
[dirname](#method-fluent-str-dirname)
151+
[encrypt](#method-fluent-str-encrypt)
150152
[endsWith](#method-fluent-str-ends-with)
151153
[exactly](#method-fluent-str-exactly)
152154
[excerpt](#method-fluent-str-excerpt)
@@ -2140,6 +2142,21 @@ $containsAll = Str::of('This is my name')->containsAll(['MY', 'NAME'], ignoreCas
21402142
// true
21412143
```
21422144

2145+
<a name="method-fluent-str-decrypt"></a>
2146+
#### `decrypt` {.collection-method}
2147+
2148+
The `decrypt` method [decrypts](/docs/{{version}}/encryption) the encrypted string:
2149+
2150+
```php
2151+
use Illuminate\Support\Str;
2152+
2153+
$decrypted = $encrypted->decrypt();
2154+
2155+
// 'secret'
2156+
```
2157+
2158+
For the inverse of `decrypt`, see the [encrypt](#method-fluent-str-encrypt) method.
2159+
21432160
<a name="method-fluent-str-deduplicate"></a>
21442161
#### `deduplicate` {.collection-method}
21452162

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

2206+
<a name="method-fluent-str-encrypt"></a>
2207+
#### `encrypt` {.collection-method}
2208+
2209+
The `encrypt` method [encrypts](/docs/{{version}}/encryption) the string:
2210+
2211+
```php
2212+
use Illuminate\Support\Str;
2213+
2214+
$encrypted = Str::of('secret')->encrypt();
2215+
```
2216+
2217+
For the inverse of `encrypt`, see the [decrypt](#method-fluent-str-decrypt) method.
2218+
21892219
<a name="method-fluent-str-ends-with"></a>
21902220
#### `endsWith` {.collection-method}
21912221

0 commit comments

Comments
 (0)