From 2a958f6f5dce7dbce95109657cd2030c60d637bf Mon Sep 17 00:00:00 2001 From: gaomin Date: Thu, 17 Jan 2013 20:07:17 +0800 Subject: [PATCH] ... Signed-off-by: gaomin --- Decrypt/Decrypt/genpwd.cpp | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/Decrypt/Decrypt/genpwd.cpp b/Decrypt/Decrypt/genpwd.cpp index 45f498b..4f5a7ef 100644 --- a/Decrypt/Decrypt/genpwd.cpp +++ b/Decrypt/Decrypt/genpwd.cpp @@ -10,6 +10,7 @@ char(*genpwd())[16] static char (*arrpwd)[16] = NULL; static int arrindex[15] = {0}; + arrindex[length-1] = -1; if(arrpwd == NULL) { arrpwd = new char[100000][16]; @@ -27,19 +28,35 @@ char(*genpwd())[16] } for(int cur=0;cur<100000 && breakflg==0;cur++) { - for(int i=length-1,plus=1;i>=0;i--) { - arrpwd[cur][i] = ch[arrindex[i]]; - if(plus==1) { - if(++arrindex[i] == chlen) { - arrindex[i] = 0; - if (i==0) breakflg=1; - } else { - plus = 0; + for(;;){ + if (breakflg) goto RETURN; + //add + for(int i=length-1,plus=1;i>=0;i--) { + if(plus==1) { + if(++arrindex[i] == chlen) { + arrindex[i] = 0; + if (i==0) breakflg=1; + } else { + break; + } } } + //check + int upperflag = 0, numflag = 0; + for(int i=1;i=26 && arrindex[i]<=51) upperflag = 1; + if(arrindex[i]>=52 && arrindex[i]<=61) numflag = 1; + } + if(upperflag && numflag) break; + + } + + //output + for(int i=length-1,plus=1;i>=0;i--) { + arrpwd[cur][i] = ch[arrindex[i]]; } arrpwd[cur][length] = '\0'; } - +RETURN: return arrpwd; } -- 2.11.4.GIT