begin process at 2012 05 27 17:45:37
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

.Net

 > ...UN PETIT ET SIMPLE CRYPTEUR TRÈS UTILE...

...UN PETIT ET SIMPLE CRYPTEUR TRÈS UTILE...


 Information sur la source

Note :
6,67 / 10 - par 3 personnes
6,67 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :.Net Source .NET ( DotNet ) Niveau :Débutant Date de création :14/03/2003 Date de mise à jour :14/03/2003 21:15:21 Vu / téléchargé :8 173 / 183

Auteur : HotSpot

Ecrire un message privé
Site perso
Commentaire sur cette source (10)
Ajouter un commentaire et/ou une note

 Description

Voici le plus simple crypteur que la terre a connu !!! :) Mais bon je voulais juste  que cela sert d'exmple ...

Bon voila si vous avez des remarques intelligentes veuilliez s'il vous pliat les faire ;)

Source

  • /************************************************************************
  • * IRC - Internet Relay Chat, Sirck.cpp
  • * Copyright (C) 2002 Elakoui Salim
  • *
  • * This program is free software; you can redistribute it and/or modify
  • * it under the terms of the GNU General Public License as published by
  • * the Free Software Foundation; either version 1, or (at your option)
  • * any later version.
  • *
  • * This program is distributed in the hope that it will be useful,
  • * but WITHOUT ANY WARRANTY; without even the implied warranty of
  • * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • * GNU General Public License for more details.
  • *
  • * You should have received a copy of the GNU General Public License
  • * along with this program; if not, write to the Free Software
  • * Foundation, Inc., 164 Avenue de clichy 75017 Paris 0619238178
  • */
  • //Include Systeme
  • #include <windows.h>
  • #include <math.h>
  • #include <time.h>
  • //Mes Includes
  • #include "resource.h"
  • //Defines
  • #define ID_AUTO_DETECT 0
  • #define ID_CRYPTE 1
  • #define ID_DECRYPTE 2
  • #define CODE_CRYP 5203
  • //Prototypes de fonctions
  • int CALLBACK Crypt(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
  • int depard(char *Name_of_fichier,int mmm);
  • int CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
  • int CALLBACK AppDlgProc(HWND hdlg, UINT mssg, WPARAM wParam, LPARAM lParam);
  • DWORD WINAPI convert(LPVOID);
  • //Déclaration et Définition des classes et des stuctes
  • struct Header
  • {
  • public:
  • int code;
  • double octec_coded;
  • char Name_of_file[255];
  • int len_name;
  • };
  • //Varaibles Globales
  • HWND hWnd;
  • HANDLE thread = 0;
  • HANDLE th_dlg;
  • HANDLE hFile = NULL;
  • HANDLE hFile2 = NULL;
  • Header buf_haed;
  • int len_buff;
  • int len_buff2;
  • int modeb = 0;
  • int anim = 0;
  • int mode;
  • char Name_of_fichier[255];
  • char New_Name[255];
  • char buff2[255];
  • char buff[255];
  • //Les fonctions et leurs définitions
  • /************************************************************************
  • - FONCTION : WinMain
  • - ARGUMENTS : (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
  • int nCmdShow) données par le systeme
  • - RETERN : true ou false ca dépend
  • - REMARQUE : principale fonction de ce programme ! donc faire tres attention
  • dans la manipulation et a tt les therars la concernant...
  • *************************************************************************/
  • int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  • LPSTR lpCmdLine, int nCmdShow)
  • {
  • if (lpCmdLine[0] != 0)
  • {
  • depard(lpCmdLine,ID_AUTO_DETECT);//,ID_CRYPTE);
  • }
  • else
  • {
  • DialogBox(hInstance,MAKEINTRESOURCE(IDD_MAIN),NULL, (DLGPROC)AppDlgProc);
  • }
  • return TRUE;
  • }
  • /************************************************************************
  • - FONCTION : AppDlgProc
  • - ARGUMENTS : HWND hdlg, UINT mssg, WPARAM wParam, LPARAM lParam
  • - RETERN : Pas d'importance à notre échelle
  • - REMARQUE : C'est la principale fonction de procédure .... Y faire
  • tres attention
  • *************************************************************************/
  • int CALLBACK AppDlgProc(HWND hdlg, UINT mssg, WPARAM wParam, LPARAM lParam)
  • {
  • hWnd = hdlg;
  • switch (mssg)
  • {
  • case WM_INITDIALOG:
  • SetClassLong(hdlg, GCL_HICON, (long)LoadIcon(0, IDI_APPLICATION));
  • SetWindowText(hdlg,".:: @Crypter et Décrypter@ ::.");
  • SetTimer(hdlg,12,500,NULL);
  • break;
  • case WM_TIMER:
  • if (anim == 0)
  • SetWindowText(hdlg,":.: @Crypter et Décrypter@ :.:");
  • else if (anim == 1)
  • SetWindowText(hdlg,"::. @Crypter et Décrypter@ .::");
  • else
  • {
  • anim = 0;
  • return SetWindowText(hdlg,".:: @Crypter et Décrypter@ ::.");
  • }
  • anim++;
  • break;
  • case WM_COMMAND:
  • switch (wParam)
  • {
  • case IDCANCEL:
  • EndDialog(hdlg,TRUE);
  • break;
  • case ID_HELP_ABOUT:
  • DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUT), hdlg,(DLGPROC) AboutDlgProc);
  • break;
  • case IDCANCEL2:
  • OPENFILENAME ofn;
  • char szFileName[255];
  • memset(szFileName,0,255);
  • //Remplissage de la structure
  • ZeroMemory( &ofn, sizeof( OPENFILENAME ) );
  • ofn.lStructSize = sizeof( OPENFILENAME );
  • ofn.hwndOwner = hdlg;
  • ofn.hInstance = GetModuleHandle(NULL);
  • lstrcpy( szFileName, TEXT("") );
  • ofn.lpstrFile = szFileName;
  • ofn.nMaxFile = MAX_PATH;
  • ofn.Flags = OFN_FILEMUSTEXIST;
  • ofn.lpstrFilter = "Seb Files (*.SEB)\0*.SEB\0All Files (*.*)\0*.*\0";
  • ofn.lpstrTitle = "...::Décrypter un fichier::...";
  • //Utiliser la dialoque commune.. standard
  • GetOpenFileName( &ofn );
  • if (szFileName[0] != 0)
  • {
  • depard(szFileName,ID_DECRYPTE);
  • }
  • break;
  • case IDCANCEL3:
  • //Remplissage de la structure
  • ZeroMemory( &ofn, sizeof( OPENFILENAME ) );
  • ofn.lStructSize = sizeof( OPENFILENAME );
  • ofn.hwndOwner = hdlg;
  • ofn.hInstance = GetModuleHandle(NULL);
  • lstrcpy( szFileName, TEXT("") );
  • ofn.lpstrFile = szFileName;
  • ofn.nMaxFile = MAX_PATH;
  • ofn.Flags = OFN_FILEMUSTEXIST;
  • ofn.lpstrFilter = "All Files (*.*)\0*.*\0";
  • ofn.lpstrTitle = "...::Crypter un fichier::...";
  • //Utiliser la dialoque commune.. standard
  • GetOpenFileName( &ofn );
  • if (szFileName[0] != 0)
  • depard(szFileName,ID_CRYPTE);
  • break;
  • }
  • break;
  • }
  • return FALSE;
  • }
  • /************************************************************************
  • - FONCTION : AboutDlgProc
  • - ARGUMENTS : HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam
  • - RETERN : Pas d'importance...
  • - REMARQUE : La procédure de la dialogue About/a propos
  • *************************************************************************/
  • int CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
  • {
  • switch(Message)
  • {
  • case WM_COMMAND:
  • switch(LOWORD(wParam))
  • {
  • case IDCANCEL:
  • case IDOK:
  • EndDialog(hwnd, IDCANCEL);
  • break;
  • }
  • default:
  • return FALSE;
  • }
  • return TRUE;
  • }
  • /************************************************************************
  • - FONCTION : Confirm
  • - ARGUMENTS : HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam
  • - RETERN : Pas d'importance
  • - REMARQUE : C'est la procédure de la dialogue confirme....
  • *************************************************************************/
  • int CALLBACK Confirm(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
  • {
  • switch(Message)
  • {
  • case WM_INITDIALOG:
  • if (mode == ID_CRYPTE)
  • {
  • SetDlgItemText(hwnd, IDC_EDIT2,buff);
  • memset(buff2,0,255);
  • strcpy(buff2,buff);
  • len_buff2 = len_buff;
  • buff2[len_buff2-1] = 'b';
  • buff2[len_buff2-2] = 'e';
  • buff2[len_buff2-3] = 's';
  • SetDlgItemText(hwnd, IDC_EDIT3,buff2);
  • SetWindowText(hwnd,"==============> Crypter");
  • }
  • else
  • {
  • SetDlgItemText(hwnd, IDC_EDIT2,buff);
  • memset(buff2,0,255);
  • for (int i =0; i < len_buff; i++)
  • {
  • buff2[i]= 255-buf_haed.Name_of_file[i];
  • }
  • len_buff2 = buf_haed.len_name;
  • SetDlgItemText(hwnd, IDC_EDIT3,buff2);
  • SetWindowText(hwnd,"==============> Décrypter");
  • }
  • break;
  • case WM_COMMAND:
  • switch(LOWORD(wParam))
  • {
  • case IDOK:
  • if (mode == ID_CRYPTE)
  • {
  • memset(&buf_haed,0,sizeof(buf_haed));
  • for (int i =0; i < len_buff; i++)
  • {
  • buf_haed.Name_of_file[i]= 255-buff[i];
  • }
  • buf_haed.len_name = len_buff;
  • memset(New_Name,0,255);
  • GetDlgItemText(hwnd, IDC_EDIT3,New_Name,255);
  • buf_haed.code = CODE_CRYP;
  • memset(Name_of_fichier,0,255);
  • strcpy(Name_of_fichier,buff);
  • modeb = ID_CRYPTE;
  • thread = CreateThread(NULL,
  • NULL,
  • convert,
  • NULL,
  • NULL,NULL);
  • DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_CRYPT), hwnd,(DLGPROC) Crypt);
  • }
  • else //ID_DECRYPTE
  • {
  • memset(Name_of_fichier,0,255);
  • memset(New_Name,0,255);
  • strcpy(Name_of_fichier,buff);
  • GetDlgItemText(hwnd, IDC_EDIT3,New_Name,255);
  • modeb = ID_DECRYPTE;
  • thread = CreateThread(NULL,
  • NULL,
  • convert,
  • NULL,
  • NULL,NULL);
  • DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_CRYPT), hwnd,(DLGPROC) Crypt);
  • }
  • break;
  • case IDCANCEL:
  • EndDialog(hwnd, IDCANCEL);
  • break;
  • case IDPARCOURIR :
  • OPENFILENAME ofn;
  • char szFileName[255];
  • memset(szFileName,0,255);
  • // Fill out the OPENFILENAME struct
  • ZeroMemory( &ofn, sizeof( OPENFILENAME ) );
  • ofn.lStructSize = sizeof( OPENFILENAME );
  • ofn.hwndOwner = hwnd;
  • ofn.hInstance = GetModuleHandle(NULL);
  • ofn.lpstrFile = szFileName;
  • ofn.nMaxFile = MAX_PATH;
  • ofn.Flags = OFN_OVERWRITEPROMPT;
  • if (mode == ID_DECRYPTE)
  • {
  • ofn.lpstrFilter = "Seb Files (*.SEB)\0*.SEB\0";
  • ofn.lpstrDefExt = ".SEB";
  • }
  • else
  • {
  • ofn.lpstrFilter = "All Files (*.*)\0*.*\0";
  • //ofn.lpstrDefExt = ".";
  • }
  • ofn.lpstrTitle = "...Choix du fichier...";
  • // Use the common dialog
  • GetSaveFileName( &ofn );
  • if (szFileName[0] != 0)
  • SetDlgItemText(hwnd, IDC_EDIT3,szFileName);
  • break;
  • }
  • break;
  • default:
  • return FALSE;
  • }
  • return TRUE;
  • }
  • /************************************************************************
  • - FONCTION : Crypt
  • - ARGUMENTS : HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam
  • - RETERN : Pas d'importance
  • - REMARQUE : Idem
  • *************************************************************************/
  • int CALLBACK Crypt(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
  • {
  • th_dlg = hwnd;
  • switch(Message)
  • {
  • case WM_COMMAND:
  • switch(LOWORD(wParam))
  • {
  • case IDOK:
  • EndDialog(hwnd, IDOK);
  • break;
  • case IDCANCEL:
  • if (thread != 0)
  • {
  • SuspendThread(thread);
  • int y = 0;
  • if (mode == 1)
  • y = MessageBox(hwnd,"Etes vous bien sur de vouloir quitter le déroulement du decryptage???","Confirmation",MB_YESNO | MB_ICONQUESTION );
  • else
  • y = MessageBox(hwnd,"Etes vous bien sur de vouloir quitter le déroulement du cryptage???","Confirmation",MB_YESNO | MB_ICONQUESTION );
  • if (y == IDYES)
  • {
  • TerminateThread(thread,TRUE);
  • CloseHandle(hFile2);
  • CloseHandle(hFile);
  • thread = 0;
  • DeleteFile(New_Name);
  • EndDialog(hwnd, IDCANCEL);
  • }
  • else
  • ResumeThread(thread);
  • }
  • break;
  • }
  • break;
  • default:
  • return FALSE;
  • }
  • return TRUE;
  • }
  • /************************************************************************
  • - FONCTION : depard
  • - ARGUMENTS : char *Name_of_fichier,int mmm (le nouveau nom et le mode
  • voulu)
  • - RETERN : ca dépend (reussite - Echec)
  • - REMARQUE : C'est la fonction que va etudier le ficier qu'on veut
  • dé/crypter... Elle est importante dans la mesure ou elle
  • repère les fautes et dans la mesure ou elle lit le heard
  • et décode le nom.
  • *************************************************************************/
  • int depard(char *Name_of_fichier,int mmm)
  • {
  • int size = 0;
  • int i = 0;
  • memset(buff,0,255);
  • //decodage du nom
  • if (Name_of_fichier[0] == 34)
  • {
  • for (i =0 ;i < 255; i++)
  • {
  • if (Name_of_fichier[i+1] == 0 || Name_of_fichier[i+1] == 34)
  • break;
  • buff[i] = Name_of_fichier[i+1];
  • }
  • size = i;
  • }
  • else
  • {
  • for (i = 0 ;i < 255; i++)
  • {
  • if (Name_of_fichier[i] == 0)
  • break;
  • }
  • strcpy(buff,Name_of_fichier);
  • size = i;
  • }
  • len_buff = size;
  • hFile = CreateFile(buff,
  • GENERIC_READ,
  • NULL,
  • NULL,
  • OPEN_EXISTING,
  • FILE_ATTRIBUTE_NORMAL,
  • NULL);
  • if (hFile == INVALID_HANDLE_VALUE)
  • {
  • MessageBox(hWnd,buff,"Erreur Ouverture Impossible !",MB_ICONWARNING);
  • return FALSE;
  • }
  • DWORD dw;
  • ReadFile(hFile,&buf_haed,sizeof(Header),&dw,NULL);
  • CloseHandle(hFile);
  • if (mmm == ID_DECRYPTE)
  • {
  • if (dw != sizeof(Header) || CODE_CRYP != buf_haed.code)
  • {
  • MessageBox(NULL,"Ce fichier n'a pas été crypté par ce logiciel","Erreur",MB_ICONWARNING);
  • }
  • else
  • {
  • mode = ID_DECRYPTE;
  • DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_CONFIRME),hWnd,(DLGPROC) Confirm);
  • }
  • }
  • else if (mmm == ID_CRYPTE )
  • {
  • mode = ID_CRYPTE;
  • DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_CONFIRME),hWnd,(DLGPROC) Confirm);
  • }
  • else if (mmm == ID_AUTO_DETECT )
  • {
  • if (dw != sizeof(Header) || CODE_CRYP != buf_haed.code )
  • {
  • mode = ID_CRYPTE;
  • DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_CONFIRME),hWnd,(DLGPROC) Confirm);
  • }
  • else
  • {
  • mode = ID_DECRYPTE;
  • DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_CONFIRME),hWnd,(DLGPROC) Confirm);
  • }
  • }
  • return TRUE;
  • }
  • /************************************************************************
  • - FONCTION : convert
  • - ARGUMENTS : RIEN
  • - RETERN : TRUE ou FALSE
  • - REMARQUE : fonction appelé par le thread.. c'est cettte dernière qui
  • va s'occuper de la dé/cryptation :) (mot inventé)
  • *************************************************************************/
  • DWORD WINAPI convert(LPVOID)
  • {
  • if (modeb == ID_CRYPTE )
  • {
  • hFile = CreateFile(buff,
  • GENERIC_READ,
  • NULL,
  • NULL,
  • OPEN_EXISTING,
  • FILE_ATTRIBUTE_NORMAL,
  • NULL);
  • hFile2 = CreateFile(New_Name,
  • GENERIC_WRITE,
  • NULL,
  • NULL,
  • CREATE_ALWAYS,
  • FILE_ATTRIBUTE_NORMAL,
  • NULL);
  • DWORD dw;
  • /*for (int i = 0; i <
  • buf_haed.Name_of_file[i]*/
  • WriteFile(hFile2,&buf_haed,sizeof(Header),&dw,NULL);
  • if (hFile == INVALID_HANDLE_VALUE || hFile2 == INVALID_HANDLE_VALUE )
  • {
  • MessageBox(hWnd,"Eureur d'ouverture de fichier","Erreur",MB_ICONWARNING);
  • CloseHandle(hFile);
  • thread = 0;
  • EndDialog(th_dlg,IDOK);
  • return FALSE;
  • }
  • int gg = GetFileSize(hFile,NULL);
  • char *a = new char [512];
  • memset(a,0,512);
  • for (int i = 0; i < gg ; i+=512)
  • {
  • if ((i + 512 ) >= gg)
  • {
  • int y = ReadFile(hFile,a,gg-i,&dw,NULL);
  • if (y == FALSE || dw != (unsigned)(gg-i) )
  • {
  • MessageBox(hWnd,"Erreur de lecteur ! Opération echouée","Erreur",MB_ICONWARNING);
  • CloseHandle(hFile);
  • thread = 0;
  • EndDialog(th_dlg,IDOK);
  • return FALSE;
  • }
  • for (int h = 0; h < (gg-i);h++)
  • a[h] = 255-a[h];
  • y = WriteFile(hFile2,a,gg-i,&dw,NULL);
  • if (y == FALSE || dw != (unsigned)(gg-i))
  • {
  • MessageBox(hWnd,"Erreur d'écriture ! Opération echouée","Erreur",MB_ICONWARNING);
  • CloseHandle(hFile);
  • thread = 0;
  • EndDialog(th_dlg,IDOK);
  • return FALSE;
  • }
  • memset(a,0,512);
  • break;
  • }
  • else
  • {
  • int y = ReadFile(hFile,a,512,&dw,NULL);
  • if (y == FALSE || dw != 512)
  • {
  • MessageBox(hWnd,"Erreur de lecteur ! Opération echouée","Erreur",MB_ICONWARNING);
  • CloseHandle(hFile);
  • thread = 0;
  • EndDialog(th_dlg,IDOK);
  • return FALSE;
  • }
  • for (int h = 0; h < 512;h++)
  • a[h] = 255-a[h];
  • y = WriteFile(hFile2,a,512,&dw,NULL);
  • if (y == FALSE || dw != 512)
  • {
  • MessageBox(hWnd,"Erreur d'écriture ! Opération echouée","Erreur",MB_ICONWARNING);
  • CloseHandle(hFile);
  • thread = 0;
  • EndDialog(th_dlg,IDOK);
  • return FALSE;
  • }
  • memset(a,0,512);
  • }
  • }
  • CloseHandle(hFile2);
  • }
  • else
  • {
  • hFile = CreateFile(buff,
  • GENERIC_READ,
  • NULL,
  • NULL,
  • OPEN_EXISTING,
  • FILE_ATTRIBUTE_NORMAL,
  • NULL);
  • hFile2 = CreateFile(New_Name,
  • GENERIC_WRITE,
  • NULL,
  • NULL,
  • CREATE_ALWAYS,
  • FILE_ATTRIBUTE_NORMAL,
  • NULL);
  • if (hFile == INVALID_HANDLE_VALUE || hFile2 == INVALID_HANDLE_VALUE )
  • {
  • MessageBox(hWnd,"Erreur d'ouverture de fichier","Erreur",MB_ICONWARNING);
  • CloseHandle(hFile);
  • thread = 0;
  • EndDialog(th_dlg,IDOK);
  • return FALSE;
  • }
  • DWORD dw;
  • SetFilePointer(hFile,sizeof(Header),NULL,FILE_BEGIN);
  • int gg = GetFileSize(hFile,NULL)-sizeof(Header);
  • char *a = new char [512];
  • memset(a,0,512);
  • char b[255];
  • memset(b,0,255);
  • wsprintf(b,"%ld",gg);
  • for (int i = 0; i < gg ; i+=512)
  • {
  • if ((i + 512 ) >= gg)
  • {
  • int y = ReadFile(hFile,a,gg-i,&dw,NULL);
  • if (y == FALSE || dw != (unsigned)(gg-i))
  • {
  • MessageBox(hWnd,"Erreur de lecteur ! Opération echouée","Erreur",MB_ICONWARNING);
  • CloseHandle(hFile);
  • thread = 0;
  • EndDialog(th_dlg,IDOK);
  • return FALSE;
  • }
  • for (int h = 0; h < (gg-i);h++)
  • a[h] = 255-a[h];
  • y = WriteFile(hFile2,a,gg-i,&dw,NULL);
  • if (y == FALSE || dw != (unsigned)(gg-i))
  • {
  • MessageBox(hWnd,"Erreur d'écriture ! Opération echouée","Erreur",MB_ICONWARNING);
  • CloseHandle(hFile);
  • thread = 0;
  • EndDialog(th_dlg,IDOK);
  • return FALSE;
  • }
  • memset(a,0,512);
  • break;
  • }
  • else
  • {
  • int y = ReadFile(hFile,a,512,&dw,NULL);
  • if (y == FALSE || dw != 512)
  • {
  • MessageBox(hWnd,"Erreur de lecteur ! Opération echouée","Erreur",MB_ICONWARNING);
  • CloseHandle(hFile);
  • thread = 0;
  • EndDialog(th_dlg,IDOK);
  • return FALSE;
  • }
  • for (int h = 0; h < 512;h++)
  • a[h] = 255-a[h];
  • y = WriteFile(hFile2,a,512,&dw,NULL);
  • if (y == FALSE || dw != 512)
  • {
  • MessageBox(hWnd,"Erreur d'écriture ! Opération echouée","Erreur",MB_ICONWARNING);
  • CloseHandle(hFile);
  • thread = 0;
  • EndDialog(th_dlg,IDOK);
  • return FALSE;
  • }
  • memset(a,0,512);
  • }
  • }
  • CloseHandle(hFile2);
  • }
  • CloseHandle(hFile);
  • thread = 0;
  • EndDialog(th_dlg,IDOK);
  • return TRUE;
  • }
/************************************************************************
 *   IRC - Internet Relay Chat, Sirck.cpp
 *   Copyright (C) 2002 Elakoui Salim
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 1, or (at your option)
 *   any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 164 Avenue de clichy 75017 Paris 0619238178
 */

//Include Systeme
#include <windows.h>
#include <math.h>
#include <time.h>

//Mes Includes
#include "resource.h"

//Defines
#define ID_AUTO_DETECT     0
#define ID_CRYPTE          1
#define ID_DECRYPTE        2
#define CODE_CRYP 5203

//Prototypes de fonctions
int				CALLBACK Crypt(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
int				depard(char *Name_of_fichier,int mmm);
int				CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
int	CALLBACK	AppDlgProc(HWND hdlg, UINT mssg, WPARAM wParam, LPARAM lParam);
DWORD WINAPI	convert(LPVOID);


//Déclaration et Définition des classes et des stuctes
struct Header
{
public:
	int code;
	double octec_coded;
	char Name_of_file[255];
	int len_name;
};
 

//Varaibles Globales
HWND hWnd;
HANDLE thread = 0;
HANDLE th_dlg;
HANDLE hFile = NULL;
HANDLE hFile2 = NULL;
Header buf_haed;
int len_buff;
int len_buff2;
int modeb = 0;
int anim = 0;
int mode; 
char Name_of_fichier[255];
char New_Name[255];
char buff2[255];
char buff[255];

//Les fonctions et leurs définitions

/************************************************************************
-	FONCTION  : WinMain
-	ARGUMENTS : (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, 
				int nCmdShow) données par le systeme
-	RETERN	  :	true ou false ca dépend
-	REMARQUE  : principale fonction de ce programme ! donc faire tres attention 
				dans la manipulation et a tt les therars la concernant...
*************************************************************************/
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{

	if (lpCmdLine[0] != 0)
	{
		depard(lpCmdLine,ID_AUTO_DETECT);//,ID_CRYPTE);
		
	}
	else
	{
		DialogBox(hInstance,MAKEINTRESOURCE(IDD_MAIN),NULL, (DLGPROC)AppDlgProc);
	}
	return TRUE;
	
}


/************************************************************************
-	FONCTION  : AppDlgProc
-	ARGUMENTS : HWND hdlg, UINT mssg, WPARAM wParam, LPARAM lParam 
-	RETERN	  :	Pas d'importance à notre échelle
-	REMARQUE  : C'est la principale fonction de procédure .... Y faire 
				tres attention
*************************************************************************/
int CALLBACK AppDlgProc(HWND hdlg, UINT mssg, WPARAM wParam, LPARAM lParam)
{
	hWnd = hdlg;

	switch (mssg)
	{
	case WM_INITDIALOG:
		SetClassLong(hdlg, GCL_HICON, (long)LoadIcon(0, IDI_APPLICATION));
		SetWindowText(hdlg,".:: @Crypter et Décrypter@ ::.");
		SetTimer(hdlg,12,500,NULL);
		break;
	case WM_TIMER:
		if (anim == 0)
			SetWindowText(hdlg,":.: @Crypter et Décrypter@ :.:");
		else if (anim == 1)
			SetWindowText(hdlg,"::. @Crypter et Décrypter@ .::");
		else
		{
			anim = 0;
			return SetWindowText(hdlg,".:: @Crypter et Décrypter@ ::.");

		}
		anim++;
		break;
	case WM_COMMAND:
		switch (wParam)
		{
		case IDCANCEL:
			EndDialog(hdlg,TRUE);		   
			break;
		case  ID_HELP_ABOUT:
			DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUT), hdlg,(DLGPROC) AboutDlgProc);	
			break;
		case IDCANCEL2:
			OPENFILENAME    ofn;
			char szFileName[255];
			memset(szFileName,0,255);

			//Remplissage de la structure
			ZeroMemory( &ofn, sizeof( OPENFILENAME ) );
			ofn.lStructSize = sizeof( OPENFILENAME );
			ofn.hwndOwner = hdlg;
			ofn.hInstance = GetModuleHandle(NULL);
			lstrcpy( szFileName, TEXT("") );
			ofn.lpstrFile = szFileName;
			ofn.nMaxFile = MAX_PATH;
			ofn.Flags = OFN_FILEMUSTEXIST;
			ofn.lpstrFilter = "Seb Files (*.SEB)\0*.SEB\0All Files (*.*)\0*.*\0";
			ofn.lpstrTitle = "...::Décrypter un fichier::...";

			//Utiliser la dialoque commune.. standard
			GetOpenFileName( &ofn );

			if (szFileName[0] != 0)
			{
				depard(szFileName,ID_DECRYPTE);
			} 
			break;
		case IDCANCEL3:
			//Remplissage de la structure
			ZeroMemory( &ofn, sizeof( OPENFILENAME ) );
			ofn.lStructSize = sizeof( OPENFILENAME );
			ofn.hwndOwner = hdlg;
			ofn.hInstance = GetModuleHandle(NULL);
			lstrcpy( szFileName, TEXT("") );
			ofn.lpstrFile = szFileName;
			ofn.nMaxFile = MAX_PATH;
			ofn.Flags = OFN_FILEMUSTEXIST;
			ofn.lpstrFilter = "All Files (*.*)\0*.*\0";
			ofn.lpstrTitle = "...::Crypter un fichier::...";

			//Utiliser la dialoque commune.. standard
			GetOpenFileName( &ofn );
			
			if (szFileName[0] != 0)
				depard(szFileName,ID_CRYPTE);
			break;
		}
		break;
	}
	return FALSE;
}


/************************************************************************
-	FONCTION  : AboutDlgProc 
-	ARGUMENTS : HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam
-	RETERN	  :	Pas d'importance...
-	REMARQUE  : La procédure de la dialogue About/a propos
*************************************************************************/
int CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
       case WM_COMMAND:
            switch(LOWORD(wParam))
            {
				case IDCANCEL:
                case IDOK:
                    EndDialog(hwnd, IDCANCEL);
                break;
            }
        default:
            return FALSE;
    }
    return TRUE;
}


/************************************************************************
-	FONCTION  : Confirm 
-	ARGUMENTS : HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam
-	RETERN	  :	Pas d'importance
-	REMARQUE  : C'est la procédure de la dialogue confirme....
*************************************************************************/
int CALLBACK Confirm(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
	case WM_INITDIALOG:
		if (mode == ID_CRYPTE)
		{
			SetDlgItemText(hwnd, IDC_EDIT2,buff);
			memset(buff2,0,255);
			strcpy(buff2,buff);
			len_buff2 = len_buff;
			buff2[len_buff2-1] = 'b';
			buff2[len_buff2-2] = 'e';
			buff2[len_buff2-3] = 's';
			SetDlgItemText(hwnd, IDC_EDIT3,buff2);
			SetWindowText(hwnd,"==============> Crypter");
			
		}
		else
		{
			SetDlgItemText(hwnd, IDC_EDIT2,buff);
			memset(buff2,0,255);
			for (int i =0; i < len_buff; i++)
			{
				buff2[i]= 255-buf_haed.Name_of_file[i];
			}

		
			len_buff2 = buf_haed.len_name;
			SetDlgItemText(hwnd, IDC_EDIT3,buff2);
			SetWindowText(hwnd,"==============> Décrypter");

		}
		break;
	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
			case IDOK:
				if (mode == ID_CRYPTE)
				{
					memset(&buf_haed,0,sizeof(buf_haed));
					for (int i =0; i < len_buff; i++)
					{
						buf_haed.Name_of_file[i]= 255-buff[i];
					}
					
					buf_haed.len_name = len_buff;
					memset(New_Name,0,255);
					
					GetDlgItemText(hwnd, IDC_EDIT3,New_Name,255);
					buf_haed.code = CODE_CRYP;
					memset(Name_of_fichier,0,255);
					strcpy(Name_of_fichier,buff);
					
					modeb = ID_CRYPTE;
					thread = CreateThread(NULL,
						 NULL,
						 convert,
						 NULL,
						 NULL,NULL);

					DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_CRYPT), hwnd,(DLGPROC) Crypt);
				}
				else //ID_DECRYPTE
				{
					memset(Name_of_fichier,0,255);
					memset(New_Name,0,255);
					strcpy(Name_of_fichier,buff);
					GetDlgItemText(hwnd, IDC_EDIT3,New_Name,255);

					modeb = ID_DECRYPTE;
					thread = CreateThread(NULL,
						 NULL,
						 convert,
						 NULL,
						 NULL,NULL);

					DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_CRYPT), hwnd,(DLGPROC) Crypt);					
				}
				break;
			case IDCANCEL:
				EndDialog(hwnd, IDCANCEL);
			break;
			case IDPARCOURIR :
				OPENFILENAME    ofn;
				char szFileName[255];
				memset(szFileName,0,255);
					
				// Fill out the OPENFILENAME struct
				ZeroMemory( &ofn, sizeof( OPENFILENAME ) );
				ofn.lStructSize = sizeof( OPENFILENAME );
				ofn.hwndOwner = hwnd;
				ofn.hInstance = GetModuleHandle(NULL);
				
				ofn.lpstrFile = szFileName;
				ofn.nMaxFile = MAX_PATH;
				ofn.Flags = OFN_OVERWRITEPROMPT;
				
				if (mode == ID_DECRYPTE)
				{
					ofn.lpstrFilter = "Seb Files (*.SEB)\0*.SEB\0";
					ofn.lpstrDefExt = ".SEB";
				}
				else
				{
					ofn.lpstrFilter = "All Files (*.*)\0*.*\0";
					//ofn.lpstrDefExt = ".";
				}
				ofn.lpstrTitle = "...Choix du fichier...";

				// Use the common dialog
				GetSaveFileName( &ofn );
				if (szFileName[0] != 0)
					SetDlgItemText(hwnd, IDC_EDIT3,szFileName);
				break;
		}
	break;
	default:
		return FALSE;
    }
    return TRUE;
}

/************************************************************************
-	FONCTION  : Crypt
-	ARGUMENTS : HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam
-	RETERN	  :	Pas d'importance
-	REMARQUE  : Idem
*************************************************************************/
int CALLBACK Crypt(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
	th_dlg = hwnd;
    switch(Message)
    {
       case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case IDOK:
                    EndDialog(hwnd, IDOK);
                break;
                case IDCANCEL:
					if (thread != 0)
					{
						SuspendThread(thread);
						int y = 0;
						if (mode == 1)
							y = MessageBox(hwnd,"Etes vous bien sur de vouloir quitter le déroulement du decryptage???","Confirmation",MB_YESNO | MB_ICONQUESTION );
						else
							y = MessageBox(hwnd,"Etes vous bien sur de vouloir quitter le déroulement du cryptage???","Confirmation",MB_YESNO | MB_ICONQUESTION );
						if (y == IDYES)
						{
							TerminateThread(thread,TRUE);
							CloseHandle(hFile2);
							CloseHandle(hFile);
							thread = 0;
							DeleteFile(New_Name);
							EndDialog(hwnd, IDCANCEL);
						}
						else
							ResumeThread(thread);
					}
                    
                break;
            }
        break;
		
        default:
            return FALSE;
    }
    return TRUE;
}

 
/************************************************************************
-	FONCTION  : depard
-	ARGUMENTS : char *Name_of_fichier,int mmm (le nouveau nom et le mode 
				voulu)
-	RETERN	  :	ca dépend (reussite - Echec)
-	REMARQUE  : C'est la fonction que va etudier le ficier qu'on veut 
				dé/crypter... Elle est importante dans la mesure ou elle 
				repère les fautes et dans la mesure ou elle lit le heard 
				et décode le nom.
*************************************************************************/
int depard(char *Name_of_fichier,int mmm)
{
	
	int size = 0;
	int i =  0;

	memset(buff,0,255);


	 //decodage du nom
	if (Name_of_fichier[0] == 34)
	{
		for (i =0 ;i < 255; i++)
		{
			if (Name_of_fichier[i+1] == 0 || Name_of_fichier[i+1] == 34)
				break;	
			buff[i] = Name_of_fichier[i+1];
		}
		size = i;

	}
	else
	{
		for (i = 0 ;i < 255; i++)
		{
			if (Name_of_fichier[i] == 0)
				break;
		}
		strcpy(buff,Name_of_fichier);
		size = i;

	}
	

	
	len_buff = size;
	hFile = CreateFile(buff,
		GENERIC_READ,
		NULL, 
		NULL,
		OPEN_EXISTING,
		FILE_ATTRIBUTE_NORMAL,
		NULL);

	

	if (hFile == INVALID_HANDLE_VALUE)
	{
		MessageBox(hWnd,buff,"Erreur Ouverture Impossible !",MB_ICONWARNING);
		return FALSE;
	}


	DWORD dw;
	ReadFile(hFile,&buf_haed,sizeof(Header),&dw,NULL);
	

	CloseHandle(hFile);
		
	if (mmm == ID_DECRYPTE)
	{
		if (dw != sizeof(Header) || CODE_CRYP != buf_haed.code)
		{
			MessageBox(NULL,"Ce fichier n'a pas été crypté par ce logiciel","Erreur",MB_ICONWARNING);
		}
		else
		{
			mode = ID_DECRYPTE;
			DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_CONFIRME),hWnd,(DLGPROC) Confirm);
		}

	}
	else  if (mmm == ID_CRYPTE )
	{
		mode = ID_CRYPTE;
		DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_CONFIRME),hWnd,(DLGPROC) Confirm);
	}
	else if (mmm == ID_AUTO_DETECT )
	{
		if (dw != sizeof(Header) || CODE_CRYP != buf_haed.code )
		{
			mode = ID_CRYPTE;
			DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_CONFIRME),hWnd,(DLGPROC) Confirm);
		}
		else
		{
		   	mode = ID_DECRYPTE;
			DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_CONFIRME),hWnd,(DLGPROC) Confirm);
		}
	}
	return TRUE;
}

/************************************************************************
-	FONCTION  : convert
-	ARGUMENTS : RIEN
-	RETERN	  :	TRUE ou FALSE
-	REMARQUE  : fonction appelé par le thread.. c'est cettte dernière qui 
				va s'occuper de la dé/cryptation :) (mot inventé)
*************************************************************************/
DWORD WINAPI convert(LPVOID)
{
	
	if (modeb == ID_CRYPTE )
	{
		hFile = CreateFile(buff,
		GENERIC_READ,
		NULL, 
		NULL,
		OPEN_EXISTING,
		FILE_ATTRIBUTE_NORMAL,
		NULL);

		hFile2 = CreateFile(New_Name,
		GENERIC_WRITE,
		NULL, 
		NULL,
		CREATE_ALWAYS,
		FILE_ATTRIBUTE_NORMAL,
		NULL);
		DWORD dw;
		/*for (int i = 0; i <  
		buf_haed.Name_of_file[i]*/
		WriteFile(hFile2,&buf_haed,sizeof(Header),&dw,NULL);
		if (hFile == INVALID_HANDLE_VALUE || hFile2 == INVALID_HANDLE_VALUE )
		{
			MessageBox(hWnd,"Eureur d'ouverture de fichier","Erreur",MB_ICONWARNING);
			CloseHandle(hFile);
			thread = 0;
			EndDialog(th_dlg,IDOK);
	   		return FALSE;
		}

		int gg = GetFileSize(hFile,NULL);
		char *a = new char [512];
		memset(a,0,512);

		for (int i = 0; i < gg ; i+=512)
		{

			if ((i + 512 ) >= gg)
			{
				int y = ReadFile(hFile,a,gg-i,&dw,NULL);

				
				

				if (y == FALSE || dw != (unsigned)(gg-i) )
				{
					MessageBox(hWnd,"Erreur de lecteur ! Opération echouée","Erreur",MB_ICONWARNING);
					CloseHandle(hFile);
					thread = 0;
					EndDialog(th_dlg,IDOK);
	   				return FALSE;
				}
				for (int h = 0; h < (gg-i);h++)
					a[h] = 255-a[h];
				y = WriteFile(hFile2,a,gg-i,&dw,NULL);
				if (y == FALSE || dw != (unsigned)(gg-i))
				{
					MessageBox(hWnd,"Erreur d'écriture ! Opération echouée","Erreur",MB_ICONWARNING);
					CloseHandle(hFile);
					thread = 0;
					EndDialog(th_dlg,IDOK);
	   				return FALSE;
				}

				memset(a,0,512);
				break;
			}
			else
			{
				int y = ReadFile(hFile,a,512,&dw,NULL);
				
				if (y == FALSE || dw != 512)
				{
					MessageBox(hWnd,"Erreur de lecteur ! Opération echouée","Erreur",MB_ICONWARNING);
					CloseHandle(hFile);
					thread = 0;
					EndDialog(th_dlg,IDOK);
	   				return FALSE;
				}
				for (int h = 0; h < 512;h++)
					a[h] = 255-a[h];
				y = WriteFile(hFile2,a,512,&dw,NULL);
				if (y == FALSE || dw != 512)
				{
					MessageBox(hWnd,"Erreur d'écriture ! Opération echouée","Erreur",MB_ICONWARNING);
					CloseHandle(hFile);
					thread = 0;
					EndDialog(th_dlg,IDOK);
	   				return FALSE;
				}

				memset(a,0,512);
			}

		}

		CloseHandle(hFile2);
	}
	else
	{
		hFile = CreateFile(buff,
		GENERIC_READ,
		NULL, 
		NULL,
		OPEN_EXISTING,
		FILE_ATTRIBUTE_NORMAL,
		NULL);

		hFile2 = CreateFile(New_Name,
		GENERIC_WRITE,
		NULL, 
		NULL,
		CREATE_ALWAYS,
		FILE_ATTRIBUTE_NORMAL,
		NULL);
		if (hFile == INVALID_HANDLE_VALUE || hFile2 == INVALID_HANDLE_VALUE )
		{
			MessageBox(hWnd,"Erreur d'ouverture de fichier","Erreur",MB_ICONWARNING);
			CloseHandle(hFile);
			thread = 0;
			EndDialog(th_dlg,IDOK);
	   		return FALSE;
		}
		DWORD dw;

		SetFilePointer(hFile,sizeof(Header),NULL,FILE_BEGIN);
		
		int gg = GetFileSize(hFile,NULL)-sizeof(Header);
		char *a = new char [512];
		memset(a,0,512);
	
		char b[255];
		memset(b,0,255);
		wsprintf(b,"%ld",gg);
		
		for (int i = 0; i < gg ; i+=512)
		{

			if ((i + 512 ) >= gg)
			{
				int y = ReadFile(hFile,a,gg-i,&dw,NULL);
						

				if (y == FALSE || dw != (unsigned)(gg-i))
				{
					MessageBox(hWnd,"Erreur de lecteur ! Opération echouée","Erreur",MB_ICONWARNING);
					CloseHandle(hFile);
					thread = 0;
					EndDialog(th_dlg,IDOK);
	   				return FALSE;
				}
				for (int h = 0; h < (gg-i);h++)
					a[h] = 255-a[h];
				y = WriteFile(hFile2,a,gg-i,&dw,NULL);
				if (y == FALSE || dw != (unsigned)(gg-i))
				{
					MessageBox(hWnd,"Erreur d'écriture ! Opération echouée","Erreur",MB_ICONWARNING);
					CloseHandle(hFile);
					thread = 0;
					EndDialog(th_dlg,IDOK);
	   				return FALSE;
				}

				memset(a,0,512);
				break;
			}
			else
			{
				int y = ReadFile(hFile,a,512,&dw,NULL);
				
				if (y == FALSE || dw != 512)
				{
					MessageBox(hWnd,"Erreur de lecteur ! Opération echouée","Erreur",MB_ICONWARNING);
					CloseHandle(hFile);
					thread = 0;
					EndDialog(th_dlg,IDOK);
	   				return FALSE;
				}
				for (int h = 0; h < 512;h++)
					a[h] = 255-a[h];
				y = WriteFile(hFile2,a,512,&dw,NULL);
				
				if (y == FALSE || dw != 512)
				{
					MessageBox(hWnd,"Erreur d'écriture ! Opération echouée","Erreur",MB_ICONWARNING);
					CloseHandle(hFile);
					thread = 0;
					EndDialog(th_dlg,IDOK);
	   				return FALSE;
				}

				memset(a,0,512);
			}

		}

		CloseHandle(hFile2);

	
	}
	CloseHandle(hFile);
	thread = 0;
	EndDialog(th_dlg,IDOK);
	return TRUE;
}



 Conclusion

Bon voila ....

COMMENTAIRE !

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources du même auteur

CALCULE DE POLYNOME AVEC ET SANS LA METHODE DE HORNER
Source avec Zip CLIENT IRC SIMPLE !

 Sources de la même categorie

Source avec Zip Source avec une capture ANALYSEUR LEXICAL par Donald180v
Source avec Zip Source avec une capture MAP_MAKER_JEU par seekplus
Source avec Zip Source avec une capture Source .NET (Dotnet) EMISSION D'UN OCTET SUR LE PORT SÉRIE - CLASSE SERIALPORT par jmchatelet01
Source avec Zip Source .NET (Dotnet) RESOLV EQU DE DEGRES N par darckangel731
Source avec Zip Source avec une capture Source .NET (Dotnet) INTEROP XCHAT / .NET : CHARGEUR DE PLUGINS MANAGÉS par TeBeCo

Commentaires et avis

Commentaire de BruNews le 15/03/2003 00:42:49 administrateur CS

Salut,
enfin du Win32 code en Win32, tout n'est pas perdu.
#include &lt;time.h&gt; , je n'ai pas vu ou il t'est utile, de plus il est obsolete sur Win32 qui a tout en mieux dans kernel32.dll.
dw = 0; ReadFile(hFile,a,gg-i,&dw,NULL);
inutile de tester le retour de ReadFile() puisque tu vas tester dw, suffit qu'il soit a 0 avant lecture ou ecriture pour savoir si ok.
Bon Win32
ciao...

Commentaire de HotSpot le 15/03/2003 23:58:25

Merci ....

Commentaire de teacher le 16/03/2003 20:48:43

Pourquoi mettre ce code dans la rubrique des sources NET ?
j'ai peut être pas tous compris.
Enfin il est pas le seul.

Commentaire de BruNews le 16/03/2003 20:53:33 administrateur CS

Faudrait qu'il n'y ait pas de categ par defaut lors d'un nouveau source et qu'on soit oblige de choisir.
Errare progamum est.

Commentaire de HotSpot le 17/03/2003 15:22:01

merci g compris ....pour le .NET g meme pas fait expret .. désolé :)

Commentaire de bobidop le 30/04/2003 16:01:37

répondé moi svp, moi ki comence a peine le programmation, èce vraiment le plus simple des crypteur? parcke la jme tu lol, nan serieux c vrai,??

Commentaire de BruNews le 30/04/2003 17:04:57 administrateur CS

Salut,
petits trucs mais importants:
char buff[255]; NON ne presume pas que ton compilo travaillera bien a ta place. Aligne tes donnees au mini sur multiple de 4 donc char buff[256];
N'ouvre pas 2 handle de fichier et tester sur les 2 pour savoir si ok, teste au 1er (vu dans convert()). Pourquoi creer le second si t'as pas pu ouvrir le 1er ?
Pour ton cryptage, rassure toi, on peut a peine lui donner ce nom.

Commentaire de HotSpot le 30/04/2003 18:20:02

LOL ... merci pour cette information :)
Et oui c le plus simple des crypteur (a mon que fasse un sous dos mais bon ..)
Merci pour cette remarque ..

Commentaire de Iwin le 13/08/2003 01:51:10

Heu, c assez redondant comme truc nan ? Et si g bien compris, tu ne fais que décaler les lettres (ou symbole dans la table (ASCII?)), donc c bien la plus simple des méthodes de cryptage.

Commentaire de SfyLer le 05/05/2004 23:18:26

Source trop longue -&gt; zip direct la met pas ici
a part sa c'est du bon boulot, c'est le type de cryptage a la ceasar ;o) bien codé

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,655 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales