Reemplace toda la cadena con estrellas
Frecuentes
Visto 5,287 veces
5
I need a solution to replace whole string with stars in PHP, for example there are strings like:
prueba
test123
test1234
And depends on string length, it will replace string with the stars like:
test
has 4 characters in length so it will be replaced with 4 stars ****
.
test123
has 7 characters in length so it will be replaced with 7 stars *******
. Y así...
Is there any good solution for that?
1 Respuestas
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas php replace or haz tu propia pregunta.
I really hope you are not utilizing simple masking to hide sensitive data (such as passwords). This method is extremely unsecured. - PenguinCoder
@PenguinCoder Well, I'm using it to hide some special codes. But may I know why are you calling this method extremely unsecured? - Cyclone
It would mean your methods of storing sensitive data are insecure, not particularly the masking itself. IE, if you're storing passwords (or other sensitive data) in plaintext anywhere, then its just a matter of time before someone gets their hands on your 'secured' data. - PenguinCoder
Well, its not really sensitive data, as its only a safebox code password in the game, but user will have to login on his account in order to see that stars password. So I guess its okay? - Cyclone
So I guess its okay? - What constitutes acceptable risk is completely up to you (or your supervisor if such is a work project) to determine. My comment was to bring attention to the method, and perhaps help you think of a better or more secure solution if my statement was indeed the case. - PenguinCoder