Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <stdio.h>
- #include <ctype.h>
- #include <stdlib.h>
- #include <string.h>
- //link soal : https://www.dropbox.com/s/m6oztmzpuvy6m8e/O1-T0316-WM01-05.pdf?dl=0
- int main(){
- pid_t pFork;
- int pi[2];
- char pass[100];
- int huruf,angka,ascii,i,pStrength;
- if(pipe(pi)<0)
- printf("Pipe ERROR");
- pFork=fork();
- if(pFork<0)
- printf("Error");
- else if(pFork==0){
- printf("Child Process\n===========\n");
- do{
- printf("Masukan Password[5-20]: ");
- scanf("%s",pass);getchar();
- }while(strlen(pass)>20||strlen(pass)<5);
- close(pi[0]);
- write(pi[1],&pass,sizeof(pass));
- sleep(1);
- }
- else if(pFork>0){
- close(pi[1]);
- read(pi[0],&pass,sizeof(pass));
- printf("Parent Process\n===========\n");
- printf("Your Password is \"%s \" \n",pass);
- huruf=0;
- angka=0;
- ascii=0;
- for(i=0;i<strlen(pass);i++){
- if(isalpha(pass[i]))
- huruf++;
- else if(isdigit(pass[i]))
- angka++;
- else
- ascii++;
- }
- printf("Jumlah Huruf : %d\n",huruf);
- printf("Jumlah Angka : %d\n",angka);
- printf("Jumlah ASCII : %d\n",ascii);
- printf("Panjang Pswd : %ld\n",strlen(pass));
- pStrength=0;
- if(strlen(pass)>=5&&strlen(pass)<=13)
- pStrength++;
- else if(strlen(pass)>13)
- pStrength+=2;
- if(huruf>=2&&huruf<=3)
- pStrength++;
- else if(huruf>3)
- pStrength+=2;
- if(angka>=2&&angka<=3)
- pStrength++;
- else if(angka>3)
- pStrength+=2;
- if(ascii>=2&&ascii<=3)
- pStrength++;
- else if(ascii>3)
- pStrength+=2;
- if(pStrength<4)
- printf("Password Lemah\n");
- else if(pStrength<=6)
- printf("Password Normal\n");
- else
- printf("Password Kuat\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement