/ Published in: C++
This piece of code is aimed to encrypt passwords, but this time it won't return a single character array, but a constantly-changing matrix which contains the password.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include <iostream> #include <string.h> using namespace std; void main(){ char matrix[50][50]={0}; char password[30]={0}; for(int i=0;i<50;i++){//defining matrix for(int j=0;j<50;j++){ matrix[i][j]=rand()&(90)+33; } } cout<<"Type password: "; cin>>password; system("cls"); cout<<"Type password: "; for(int i=0;i<strlen(password);i++){ cout<<"*"; }cout<<endl; cout<<"Length of typed password: "<<strlen(password)<<endl; while(1){ cout<<"Type password: "; for(int i=0;i<strlen(password);i++){ cout<<"*"; }cout<<endl; for(int i=0;i<50;i++){//defining matrix for(int j=0;j<50;j++){ matrix[i][j]=rand()%(90)+33; } } for(int l=0;l<strlen(password);l++){ matrix[l][rand()%(21)+13]=password[l];//between columns 13 and 36 } for(int k=0;k<50;k++){ for(int l=0;l<50;l++){ cout<<matrix[k][l]; }cout<<endl; } system("cls"); } system("pause"); }
URL: http://programmingeiger824.blogspot.com