Hidden password
#1

I have a plugin to send emails to my users. An email is sent when they register, and it shows their password.

Say my password was 'password', i'd like it to say

p******d

Just showing the first and last letters.

What's the simplest way to do this? Create a new string, extract the first and last character, then strins() the strlen of their password-2?
Reply
#2

Here's my whack at it.

pawn Код:
//input = what they typed for pass
new pass[MAX_PASSWORD]="**********************";
format(pass,MAX_PASSWORD,"%s%s%s",input[0],pass[strlen(pass)-strlen(input)+2],input[strlen(input)-1]);
print(pass);
Reply
#3

It didn't work, but I edited it a bit and got it to work.

pawn Код:
new pass[21]="********************";
new first[2];
strmid(first, input, 0, 1);
format(pass,24,"%s%s%s",first,pass[(22-strlen(input))],input[strlen(input)-1]);
print(pass);
Thank you for starting me off
Reply
#4

eh yeah, I shoulda put "%c%s%s" instead of "%s%s%s"
Reply
#5

How to install
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)