Разработка программы, генерирующей пароли пользователей
Курсовой проект - Компьютеры, программирование
Другие курсовые по предмету Компьютеры, программирование
GENERIROVANIE”. После чего в окошке появится сгенеррированный пароль. Далее необходимо запомнить пароль и использовать по назначению. При повторном нажатии на клавишу пароль будет сгенерирован вновь. Для выхода из программы необходимо нажать на клавишу “Выход” или нажав на “крестик”.
Заключение
В процессе выполнения курсового проекта была разработана программа, генерирующая пароли пользователей. Программа была написана при помощи интегрированной среды разработки Visual C++. Программа соответствует всем функциональным требованиям, заданным на курсовое проектирование. Взаимодействие с пользователем осуществляется с помощью графического интерфейса.
Таким образом, задание на курсовое проектирование было полностью выполнено.
Список использованных источников
1
2
3 Келецкий Я. Энциклопедия языка Си/ Пер. с англ.- М.: Мир, 1992. -687с.
4 Керниган Б., Ричи Д., Фьюер А. Язык программирования Си. Задачи по языку С/ Пер. с англ. - М.: Финансы и статистика, 1985.-279с.
ПРИЛОЖЕНИЕ А
Алгоритм программы
-----------[с листа2
--------------[на лист 2
Рисунок А.1. Алгоритм программы
---------------------------------------[с листа 1
------[на лист 1
Рисунок А.1. Лист №2
ПРИЛОЖЕНИЕ Б
Текст программы
// Password.cpp: implementation of the Password class.
//////////////////////////////////////////////////////////////////////
#include
#include "stdafx.h"
#include "PassGen.h"
#include "Password.h"
#include "Random.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Password::Password(int l)
{length = l;
passwrd = new char [length+1];
dicstr = new char [length+1];
PassAlfavit = new char [36];
HowMuchn = new int [length];
dicstr[length]=\0;
ValueOfDictionary= 134547;}
Password::~Password()
{delete(passwrd);
delete(dicstr);
delete(PassAlfavit);
delete(HowMuchn);}
void Password::GenAlfavit()
{char symbol=A;
for (int index=0;index<36;index++)
{if (index==26)
symbol=0;
PassAlfavit[index]=symbol;
symbol++;}}
char * Password::GetPassword()
{return passwrd;}
void Password::GenPass()
{Random rnd1;
for (int index =0;index<length;index++)
passwrd[index]=PassAlfavit[rnd1.NextR(35)];
passwrd[index]=\0;}
BOOL Password::TestChar()
{ClearMass(length,HowMuchn);
for (int index1=0;index1<length;index1++)
for (int index2=0;index2<length;index2++)
if (passwrd[index1]==passwrd[index2])
HowMuchn[index1]++;
if (HowMuch(length,HowMuchn))
return TRUE;
else return FALSE;}
void Password::ClearMass(int length,int * mass)
{for (int index =0;index<length;index++)
mass[index]=0;}
BOOL Password::HowMuch(int length, int *HowMuch)
{for (int index =0;index<length;index++)
if (HowMuch[index]>1)
return FALSE;
return TRUE;}
BOOL Password::TestDictionary()
{CFile Dictionary;
Try
{Dictionary.Open("length08.txt",CFile.modeRead,NULL);}
catch(CFileException *e )
{Dictionary.Abort(); // close file safely and quietly
e->~CFileException();
MessageBox(0,"Не удается открыть словарь", "ошибка", MB_APPLMODAL|MB_OK|MB_ICONSTOP);
return FALSE;}
for (int index =0;index<ValueOfDictionary;index++)
{Dictionary.Read(dicstr,8);
Dictionary.Seek(2,CFile.current);
if (Compare(length))
return FALSE;}
Dictionary.Close();
return TRUE;}
int Password::Compare(int length)
{for (int index=0;index<length;index++)
if (passwrd[index]!=dicstr[index])
return 0;
return 1;}
ПРИЛОЖЕНИЕ В
Random.cpp
// Random.cpp: implementation of the Random class.
//////////////////////////////////////////////////////////////////////
#include
#include
#include
#include "stdafx.h"
#include "PassGen.h"
#include "Random.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Random::Random()
{srand(GetTickCount());}
Random::~Random()
{}
int Random::NextR(int x)
{int rnd1;
rnd1=rand();
srand(rnd1);
rnd1=rand() % x;
return rnd1;}
ПРИЛОЖЕНИЕ Г
PassGenDlg.cpp
// PassGenDlg.cpp : implementation file
#include "stdafx.h"
#include "PassGen.h"
#include "PassGenDlg.h"
#include "Password.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPassGenDlg dialog
CPassGenDlg::CPassGenDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPassGenDlg::IDD, pParent)
{//{{AFX_DATA_INIT(CPassGenDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);}
void CPassGenDlg::DoDataExchange(CDataExchange* pDX)
{CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPassGenDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP}
BEGIN_MESSAGE_MAP(CPassGenDlg, CDialog)
//{{AFX_MSG_MAP(CPassGenDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDGEN, OnGen)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPassGenDlg message handlers
BOOL CPassGenDlg::OnInitDialog()
{CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the applications main window is not a dialog
SetIcon(m_hIcon, TRUE);// Set big icon
SetIcon(m_hIcon, FALSE);// Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CPassGenDlg::OnPaint()
{if (IsIconic())
{CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);}
else
{CDialog::OnPaint();}}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CPassGenDlg::OnQueryDragIcon()
{r