forked from Tomkndn/C
-
Notifications
You must be signed in to change notification settings - Fork 2
/
salt_password.c
48 lines (42 loc) · 1.06 KB
/
salt_password.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<stdio.h>
#include<string.h>
char salty(char pass[]);
void slicing(char A[],int m, int n);
int main(){
// Salting Password.
char oldPass[100];
printf("Input Your Password: ");
scanf("%s",&oldPass);
salty(oldPass);
// fgets(oldPass,100,stdin);
char salt[50] = "123";
strcat(oldPass,salt);
printf("Your new Password is: %s\n",oldPass);
// Slicing.
printf("Now!You are using slicing.\n");
char old[100];
int m,n;
printf("Input your string: ");
// fgets(old, 100, stdin);
scanf("%s", old);
printf("Slicing from: ");
scanf("%d %d",&m,&n);
slicing(old,m,n);
return 0;
}
char salty(char pass[]){
char newPass[100];
char salt[50] = "123";
strcpy(newPass, pass);
strcat(newPass, salt);
printf("Your new Password is: %s\n",newPass);
}
void slicing(char A[], int m, int n){
char newString[50];
for (int i = m, j = 0; i <= n; i++, j++)
{
// strcpy(newString[j], A[i]);
newString[j] = A[i];
}
printf("Your new String is %s", newString);
}