[CONTEST] Cifrario di Cesare, Questo è molto semplice

« Older   Newer »
  Share  
/dev/random
CAT_IMG Posted on 27/1/2011, 17:19     +1   -1




lol comunque ti assicuro che non funziona, adesso ti camstudio xD

www.mediafire.com/?r6xuu447xd6a75w ecco
 
Top
Doch88
CAT_IMG Posted on 27/1/2011, 17:19     +1   -1




SPOILER (click to view)
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

Edited by Doch88 - 27/1/2011, 17:34
 
Top
xMasteRx
CAT_IMG Posted on 27/1/2011, 17:23     +1   -1




whoah cazzo 200 anni per scaricarlo, però io mo esco, cmq con questo script, (lo stesso che ho postato) funziona! u.U
SPOILER (click to view)
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
 
Top
/dev/random
CAT_IMG Posted on 27/1/2011, 17:41     +1   -1




CITAZIONE (Doch88 @ 27/1/2011, 17:19) 
SPOILER (click to view)
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
SPOILER (click to view)
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
 
Top
Doch88
CAT_IMG Posted on 27/1/2011, 17:46     +1   -1




CITAZIONE (/dev/random @ 27/1/2011, 17:41) 
CITAZIONE (Doch88 @ 27/1/2011, 17:19) 
SPOILER (click to view)
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 :(

Come non va? l'ho appena provato e funziona..
 
Top
/dev/random
CAT_IMG Posted on 27/1/2011, 17:51     +1   -1




Che compilatore usi?
 
Top
Doch88
CAT_IMG Posted on 27/1/2011, 17:57     +1   -1




gcc
 
Top
/dev/random
CAT_IMG Posted on 27/1/2011, 21:29     +1   -1




Ah lol io ho provato dev-c++ sotto winzoz...
 
Top
xMasteRx
CAT_IMG Posted on 28/1/2011, 01:00     +1   -1




CITAZIONE (/dev/random @ 27/1/2011, 17:41) 
lol adesso funziona... bah i misteri di /dev/random xD

LoL se io avevo detto che funzionava ... u.u cmq cosè il premio per chi vince il contest? XD
 
Top
/dev/random
CAT_IMG Posted on 28/1/2011, 08:41     +1   -1




Un buono per un cazzotto in faccia xDxD
 
Top
Doch88
CAT_IMG Posted on 29/1/2011, 17:26     +1   -1




CITAZIONE (/dev/random @ 27/1/2011, 21:29) 
Ah lol io ho provato dev-c++ sotto winzoz...

Che problemi ti dà? non ho messo niente che rovinasse la compatibilità con altri os..
 
Top
/dev/random
CAT_IMG Posted on 29/1/2011, 17:56     +1   -1




CITAZIONE (Doch88 @ 29/1/2011, 17:26) 
CITAZIONE (/dev/random @ 27/1/2011, 21:29) 
Ah lol io ho provato dev-c++ sotto winzoz...

Che problemi ti dà? non ho messo niente che rovinasse la compatibilità con altri os..

Penso che il problema è che gcc usa gli standard C99 e dev-c++ usa l'ASCI C, il C99 è comunque attivabile ma non capisco come :|
 
Top
26 replies since 26/1/2011, 18:01   1589 views
  Share