Matthew
Matthew

Reputation: 1655

Showing last eight characters of a decrypted string in Laravel

At the moment, I have a field within my Laravel project that requires some form of encryption, so I use the available encryption through Laravel, and decrypt using the following in my blade:

{{\Crypt::decryptString($e->SCEIN)}}

But I was curious if there was a way for me to be able to show only the last 8 characters of this field after it has been decrypted. I can't seem to find much mention of it though I do know using substr would technically get me there, I am not sure how to use it on an encrypted field.

Upvotes: 1

Views: 231

Answers (1)

Tomasz Lloyd
Tomasz Lloyd

Reputation: 521

You can wrap the whole decrypt string inside the substr function and setting -8 in the second param will give you the last 8 characters.

{{ substr( \Crypt::decryptString($e->SCEIN), -8 ) }}

Upvotes: 5

Related Questions