| /dev/random |
| | CITAZIONE (Doch88 @ 27/1/2011, 17:19) CODICE #include <stdio.h> #define N 256 char alphabet[] = "abcdefghijklmnopqrstuvwxyz"; char alphabetcap[] = "ABCDEFGHILMNOPQRSTUVWXYZ";
char * EncryptDecrypt(char * str, int num, int encrypt) { for(int a = 0;a < strlen(str);a++) { char * alph; if(isupper(str[a])) alph = alphabetcap; else alph = alphabet;
int b = 0; for(int fine = 0;b < strlen(alph) && fine == 0;b++) { if(str[a] == alph[b]) { if(encrypt == 0) { if((b+num) < strlen(alph)) { str[a] = alph[(b + num)]; fine = 1; } else { b = (b+num)-strlen(alph); str[a] = alph[b]; fine = 1; } } else { if((b-num) < strlen(alph)) { str[a] = alph[(b - num)]; fine = 1; } else { b = (b-num)+strlen(alph); str[a] = alph[b]; fine = 1; } } } } } return str; } int main() { int num, scel; char str[N]; printf("0 - Encrypt\n1 - Decrypt\n"); scanf("%d",&scel); while (getchar() != '\n'); //la solita funzione di svuotamento del buffer printf("Enter the string:\n"); fgets(str,N,stdin); printf("Key:\n"); scanf("%d",&num); if(!scel) strcpy(str,EncryptDecrypt(str,num,0)); else strcpy(str,EncryptDecrypt(str,num,1)); printf("%s",&str); return 0; } Non provato, molto disordinato e fatto in fretta xD EDIT: Caratteri speciali e accenti non inclusi xD Non va ---- CITAZIONE (xMasteRx @ 27/1/2011, 17:23) whoah cazzo 200 anni per scaricarlo, però io mo esco, cmq con questo script, (lo stesso che ho postato) funziona! u.U CODICE Opt("GUIOnEventMode", 1) $GUI=GUICreate("Cifrario di Cesare", 500, 300) GUISetOnEvent(-3, "_Exit") GUISetState() GUICtrlCreateLabel("Testo", 10, 10) $InTxt=GUICtrlCreateEdit("", 10, 30, 210, 260) GUICtrlCreateLabel("Chiave", 220, 10, 60, 20) $InChiave=GUICtrlCreateInput("", 220, 30, 60, 20, 0x2000) $ButCript=GUICtrlCreateButton("Cript", 220, 50, 60, 20) GUICtrlSetOnEvent(-1, "_Crypt") $ButDeCript=GUICtrlCreateButton("DeCript", 220, 70, 60, 20) GUICtrlSetOnEvent(-1, "_DeCrypt") GUICtrlCreateLabel("Return", 290, 10) $InFinTxt=GUICtrlCreateEdit("", 290, 30, 200, 260, 0x0800) Do Sleep(10) Until False
Func _Exit() Exit EndFunc
Func _Crypt($Decrypt=1) If Not IsDeclared("Decrypt") Then $Decrypt=1 $Txt=GUICtrlRead($InTxt) $Chiave=GUICtrlRead($InChiave) If StringLen($Txt)<1 Or StringLen($Chiave)<1 Then Return MsgBox(16, "Errore u.u", "Inserisci un testo e/o una chiave e smettila di rompere u.u") $TXT=StringUpper($TXT) $Split=StringSplit($Txt, "") $Chiave=Number($Chiave) $FinTXT="" For $x=1 To $Split[0] $ASCIICode=Asc($Split[$x]) If $ASCIICode>=65 And $ASCIICode<=90 Then $ASCIICode=$ASCIICode-65+($Chiave*$Decrypt) If $ASCIICode>24 Or $ASCIICode<0 Then $ASCIICode=$ASCIICode-Floor($ASCIICode/26)*26 EndIf If $ASCIICode<0 Then $ASCIICode+=25 $ASCIICode+=65 EndIf $FinTXT&=Chr($ASCIICode) Next GUICtrlSetData($InFinTXT, $FinTXT) EndFunc
Func _DeCrypt() _Crypt(-1) EndFunc zazzà [CRIPT 12] LMLLÀ LMLLÀ [DECRIPT 12] ZAZZÀ U.U! ecco mo esco quando torno guardo il video lol, ciau u.u lol adesso funziona... bah i misteri di /dev/random xD
| | |
| |
|