// FileStffDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Cryptest.h"
#include "FileStffDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFileStffDlg dialog
CFileStffDlg::CFileStffDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFileStffDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFileStffDlg)
m_nCompLevel = 9;
m_nNumShares = 2;
m_nThreshold = 2;
m_csFileName = _T("");
m_csSeed = _T("");
m_csReName = _T("");
//}}AFX_DATA_INIT
m_nFileType = 1;
}
void CFileStffDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFileStffDlg)
DDX_Control(pDX, BTN_RE_BROWSE, m_btnReBrowse);
DDX_Control(pDX, BTN_FILE_BROWSE, m_btnBrowse);
DDX_Control(pDX, LIST_FILE_STUFF, m_lcFileStuff);
DDX_Control(pDX, EDIT_THRESHOLD, m_edtThreshold);
DDX_Control(pDX, EDIT_RE_NAME, m_edtReName);
DDX_Control(pDX, EDIT_NUM_SHARES, m_edtNumShare);
DDX_Control(pDX, EDIT_FILE_SEED, m_edtFileSeed);
DDX_Control(pDX, EDIT_FILE_NAME, m_edtFileName);
DDX_Text(pDX, EDIT_COMPRESSION_LEVEL, m_nCompLevel);
DDX_Text(pDX, EDIT_NUM_SHARES, m_nNumShares);
DDX_Text(pDX, EDIT_THRESHOLD, m_nThreshold);
DDX_Text(pDX, EDIT_FILE_NAME, m_csFileName);
DDX_Text(pDX, EDIT_FILE_SEED, m_csSeed);
DDX_Text(pDX, EDIT_RE_NAME, m_csReName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFileStffDlg, CDialog)
//{{AFX_MSG_MAP(CFileStffDlg)
ON_BN_CLICKED(BTN_FILE_BROWSE, OnFileBrowse)
ON_BN_CLICKED(RAD_DIGEST, OnDigest)
ON_BN_CLICKED(RAD_DISPERSE, OnDisperse)
ON_BN_CLICKED(RAD_DISPERSE_RECONTRUCT, OnDisperseRecontruct)
ON_BN_CLICKED(RAD_FILE_ENCRYPT, OnFileEncrypt)
ON_BN_CLICKED(RAD_FILE_DECRYPT, OnFileDecrypt)
ON_BN_CLICKED(RAD_GZIP, OnGzip)
ON_BN_CLICKED(RAD_GUNZIP, OnGunzip)
ON_BN_CLICKED(RAD_SECRET_SHARE, OnSecretShare)
ON_BN_CLICKED(RAD_SECRET_SHARE_RECONTRUCT, OnSecretShareRecontruct)
ON_BN_CLICKED(BTN_FILE_DOIT, OnFileDoit)
ON_BN_CLICKED(BTN_RE_BROWSE, OnReBrowse)
ON_EN_CHANGE(EDIT_COMPRESSION_LEVEL, OnChangeCompressionLevel)
ON_EN_CHANGE(EDIT_NUM_SHARES, OnChangeNumShares)
ON_EN_CHANGE(EDIT_THRESHOLD, OnChangeThreshold)
ON_WM_CLOSE()
ON_BN_CLICKED(BTN_EXIT, OnExit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFileStffDlg message handlers
BOOL CFileStffDlg::OnInitDialog()
{
CDialog::OnInitDialog();
OnFileEncrypt();
CCryptestApp* pcCryptest = (CCryptestApp*) AfxGetApp();
// Setup the column headings
CRect rect;
m_lcFileStuff.GetClientRect(&rect);
// Setup the list control
ListView_SetExtendedListViewStyle(m_lcFileStuff.m_hWnd, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
m_lcFileStuff.InsertColumn( 0, _T("Digest"), LVCFMT_LEFT, 80);
m_lcFileStuff.InsertColumn( 1, _T("Bytes"), LVCFMT_LEFT, 40);
m_lcFileStuff.InsertColumn( 2, _T("Results"), LVCFMT_LEFT, (rect.Width() - 120));
pcCryptest->m_lcFileStuff = &m_lcFileStuff;
GetDlgItem(EDIT_FILE_NAME)->SetWindowText(_T("Ready - Press the button to pick a file ==> "));
GetDlgItem(EDIT_RE_NAME)->SetWindowText(_T("Re-construct - Press the button to pick files ==> "));
GetDlgItem(EDIT_FILE_SEED)->SetWindowText(_T("Set the 'Secret Share Seed'!"));
EnableDoiIt();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CFileStffDlg::OnOK()
{
//CDialog::OnOK();
}
void CFileStffDlg::OnCancel()
{
//CDialog::OnCancel();
}
void CFileStffDlg::OnClose()
{
CDialog::OnOK();
}
void CFileStffDlg::OnExit()
{
OnClose();
}
void CFileStffDlg::OnFileBrowse()
{
// maximum common dialog buffer size
char bigBuff[2048] = "";
CString csFilter = _T("");
DWORD dwFlags = 0;
switch (m_nFileType)
{
case 1:
case 2:
case 4:
case 6:
case 8:
csFilter = _T("All Files (*.*)|*.*||");
break;
case 3:
csFilter = _T("Dispersed Files (*.*)|*.*||");
dwFlags = OFN_EXPLORER | OFN_ALLOWMULTISELECT;
break;
case 5:
csFilter = _T("Encrypted Files (*.enc)|*.enc||");
break;
case 7:
csFilter = _T("G-Ziped Files (*.gzip)|*.gzip||");
break;
case 9:
csFilter = _T("Secret Shared Files (*.*)|*.*||");
dwFlags = OFN_EXPLORER | OFN_ALLOWMULTISELECT;
break;
}
CFileDialog dlg(TRUE, NULL, NULL, dwFlags, csFilter);
// Modify OPENFILENAME members directly to point to bigBuff
dlg.m_ofn.lpstrFile = bigBuff;
dlg.m_ofn.nMaxFile = sizeof(bigBuff);
int iReturn = dlg.DoModal();
if (iReturn == IDOK)
{
m_csFileName = dlg.GetPathName();
GetDlgItem(EDIT_FILE_NAME)->SetWindowText(m_csFileName);
}
EnableDoiIt();
}
void CFileStffDlg::OnReBrowse()
{
if ((m_nFileType == 3) || (m_nFileType == 9))
{
CCryptestApp* pcCryptest = (CCryptestApp*) AfxGetApp();
m_csaFiles.RemoveAll();
// maximum common dialog buffer size
char bigBuff[2048] = "";
CString csFilter = _T("");
DWORD dwFlags = OFN_EXPLORER | OFN_ALLOWMULTISELECT;
if (m_nFileType == 3)
csFilter = _T("Dispersed Files (*.*)|*.*||");
else if (m_nFileType == 9)
csFilter = _T("Secret Shared Files (*.*)|*.*||");
CFileDialog dlg(TRUE, NULL, NULL, dwFlags, csFilter);
// Modify OPENFILENAME members directly to point to bigBuff
dlg.m_ofn.lpstrFile = bigBuff;
dlg.m_ofn.nMaxFile = sizeof(bigBuff);
m_csReName = _T("");
int iReturn = dlg.DoModal();
if (iReturn == IDOK)
{
CString csTmp = _T("");
POSITION pos = dlg.GetStartPosition();
while (pos != NULL)
{
CString csPath = dlg.GetNextPathName(pos);
m_csaFiles.Add(csPath);
CStringArray csaTmp;
pcCryptest->Split(csPath, _T("\\"), csaTmp, FALSE);
csTmp += _T("\"") + csaTmp.GetAt(csaTmp.GetUpperBound()) + _T("\" ");
}
if (csTmp.GetLength() > 1)
m_csReName = csTmp.Left(csTmp.GetLength() - 1);
}
GetDlgItem(EDIT_RE_NAME)->SetWindowText(m_csReName);
}
EnableDoiIt();
}
void CFileStffDlg::EnableDoiIt(void)
{
UpdateData(TRUE);
switch (m_nFileType)
{
case 1:
case 2:
case 4:
case 5:
case 6:
case 7:
case 8:
if ((!m_csFileName.IsEmpty()) && ((m_csFileName.GetAt(1) == TCHAR(':')) || (m_csFileName.GetAt(1) == TCHAR('\\'))))
GetDlgItem(BTN_FILE_DOIT)->EnableWindow(TRUE);
else
GetDlgItem(BTN_FILE_DOIT)->EnableWindow(FALSE);
break;
case 3:
case 9:
if (m_csReName.Left(3) != _T("Re-"))
GetDlgItem(BTN_FILE_DOIT)->EnableWindow(TRUE);
else
GetDlgItem(BTN_FILE_DOIT)->EnableWindow(FALSE);
break;
}
}
void CFileStffDlg::OnDigest()
{
m_nFileType = 1;
GetDlgItem(BTN_FILE_DOIT)->SetWindowText(_T("Digest It"));
GetDlgItem(STATIC_FILE_INFO)->SetWindowText(_T("Calculate MD5, SHA, and RIPEMD-160 message digests"));
GetDlgItem(EDIT_FILE_NAME)->EnableWindow(TRUE);
GetDlgItem(EDIT_COMPRESSION_LEVEL)->EnableWindow(FALSE);
GetDlgItem(EDIT_NUM_SHARES)->EnableWindow(FALSE);
GetDlgItem(EDIT_THRESHOLD)->EnableWindow(FALSE);
GetDlgItem(EDIT_FILE_SEED)->EnableWindow(FALSE);
GetDlgItem(EDIT_RE_NAME)->EnableWindow(FALSE);
GetDlgItem(BTN_FILE_BROWSE)->EnableWindow(TRUE);
GetDlgItem(BTN_RE_BROWSE)->EnableWindow(FALSE);
CheckRadioButton(1020, 1028, 1028);
EnableDoiIt();
CCryptestApp* pcCryptest = (CCryptestApp*) AfxGetApp();
pcCryptest->m_nFSItemCnt = 0;
}
void CFileStffDlg::OnDisperse()
{
m_nFileType = 2;
GetDlgItem(BTN_FILE_DOIT)->SetWindowText(_T("Disperse It"));
GetDlgItem(STATIC_FILE_INFO)->SetWindowText(_T("Information disperse a file (shares will be named file.000, file.001, etc)"));
GetDlgItem(EDIT_FILE_NAME)->EnableWindow(TRUE);
GetDlgItem(EDIT_COMPRESSION_LEVEL)->EnableWindow(FALSE);
GetDlgItem(EDIT_NUM_SHARES)->EnableWindow(TRUE);
GetDlgItem(EDIT_THRESHOLD)->EnableWindow(TRUE);
GetDlgItem(EDIT_FILE_SEED)->EnableWindow(FALSE);
GetDlgItem(EDIT_RE_NAME)->EnableWindow(FALSE);
GetDlgItem(BTN_FILE_BROWSE)->EnableWindow(TRUE);
GetDlgItem(BTN_RE_BROWSE)->EnableWindow(FALSE);
CheckRadioButton(1020, 1028, 1024);
EnableDoiIt();
CCryptestApp* pcCryptest = (CCryptestApp*) AfxGetApp();
pcCryptest->m_nFSItemCnt = 0;
}
void CFileStffDlg::OnDisperseRecontruct()
{
m_nFileType = 3;
GetDlgItem(BTN_FILE_DOIT)->SetWindowText(_T("Re-Disperse It"));
GetDlgItem(STATIC_FILE_INFO)->SetWindowText(_T("Reconstruct an information-dispersed file"));
GetDlgItem(EDIT_FILE_NAME)->EnableWindow(FALSE);
GetDlgItem(EDIT_COMPRESSION_LEVEL)->EnableWindow(FALSE);
GetDlgItem(EDIT_NUM_SHARES)->EnableWindow(FALSE);
GetDlgItem(EDIT_THRESHOLD)->EnableWindow(TRUE);
GetDlgItem(EDIT_FILE_SEED)->EnableWindow(FALSE);
GetDlgItem(EDIT_RE_NAME)->EnableWindow(TRUE);
GetDlgItem(BTN_FILE_BROWSE)->EnableWindow(FALSE);
GetDlgItem(BTN_RE_BROWSE)->EnableWindow(TRUE);
CheckRadioButton(1020, 1028, 1025);
EnableDoiIt();
CCryptestApp* pcCryptest = (CCryptestApp*) AfxGetApp();
pcCryptest->m_nFSItemCnt = 0;
}
void CFileStffDlg::OnFileEncrypt()
{
m_nFileType = 4;
GetDlgItem(BTN_FILE_DOIT)->SetWindowText(_T("Encrypt It"));
GetDlgItem(STATIC_FILE_INFO)->SetWindowText(_T("Encrypt a file"));
GetDlgItem(EDIT_FILE_NAME)->EnableWindow(TRUE);
GetDlgItem(EDIT_COMPRESSION_LEVEL)->EnableWindow(FALSE);
GetDlgItem(EDIT_NUM_SHARES)->EnableWindow(FALSE);
GetDlgItem(EDIT_THRESHOLD)->EnableWindow(FALSE);
GetDlgItem(EDIT_FILE_SEED)->EnableWindow(FALSE);
GetDlgItem(EDIT_RE_NAME)->EnableWindow(FALSE);
GetDlgItem(BTN_FILE_BROWSE)->EnableWindow(TRUE);
GetDlgItem(BTN_RE_BROWSE)->EnableWindow(FALSE);
CheckRadioButton(1020, 1028, 1020);
EnableDoiIt();
CCryptestApp* pcCryptest = (CCryptestApp*) AfxGetApp();
pcCryptest->m_nFSItemCnt = 0;
}
void CFileStffDlg::OnFileDecrypt()
{
m_nFileType = 5;
GetDlgItem(BTN_FILE_DOIT)->SetWindowText(_T("Decrypt It"));
GetDlgItem(STATIC_FILE_INFO)->SetWindowText(_T("Decrypt a file"));
GetDlgItem(EDIT_FILE_NAME)->EnableWindow(TRUE);
GetDlgItem(EDIT_COMPRESSION_LEVEL)->EnableWindow(FALSE);
GetDlgItem(EDIT_NUM_SHARES)->EnableWindow(FALSE);
GetDlgItem(EDIT_THRESHOLD)->EnableWindow(FALSE);
GetDlgItem(EDIT_FILE_SEED)->EnableWindow(FALSE);
GetDlgItem(EDIT_RE_NAME)->EnableWindow(FALSE);
GetDlgItem(BTN_FILE_BROWSE)->EnableWindow(TRUE);
GetDlgItem(BTN_RE_BROWSE)->EnableWindow(FALSE);
CheckRadioButton(1020, 1028, 1021);
EnableDoiIt();
CCryptestApp* pcCryptest = (CCryptestApp*) AfxGetApp();
pcCryptest->m_nFSItemCnt = 0;
}
void CFileStffDlg::OnGzip()
{
m_nFileType = 6;
GetDlgItem(BTN_FILE_DOIT)->SetWindowText(_T("G-Zip It"));
GetDlgItem(STATIC_FILE_INFO)->SetWindowText(_T("G-Zip a file"));
GetDlgItem(EDIT_FILE_NAME)->EnableWindow(TRUE);
GetDlgItem(EDIT_COMPRESSION_LEVEL)->EnableWindow(TRUE);
GetDlgItem(EDIT_NUM_SHARES)->EnableWindow(FALSE);
GetDlgItem(EDIT_THRESHOLD)->EnableWindow(FALSE);
GetDlgItem(EDIT_FILE_SEED)->EnableWindow(FALSE);
GetDlgItem(EDIT_RE_NAME)->EnableWindow(FALSE);
GetDlgItem(BTN_FILE_BROWSE)->EnableWindow(TRUE);
GetDlgItem(BTN_RE_BROWSE)->EnableWindow(FALSE);
CheckRadioButton(1020, 1028, 1026);
EnableDoiIt();
CCryptestApp* pcCryptest = (CCryptestApp*) AfxGetApp();
pcCryptest->m_nFSItemCnt = 0;
}
void CFileStffDlg::OnGunzip()
{
m_nFileType = 7;
GetDlgItem(BTN_FILE_DOIT)->SetWindowText(_T("G-Unzip It"));
GetDlgItem(STATIC_FILE_INFO)->SetWindowText(_T("G-Unzip a file"));
GetDlgItem(EDIT_FILE_NAME)->EnableWindow(TRUE);
GetDlgItem(EDIT_COMPRESSION_LEVEL)->EnableWindow(FALSE);
GetDlgItem(EDIT_NUM_SHARES)->EnableWindow(FALSE);
GetDlgItem(EDIT_THRESHOLD)->EnableWindow(FALSE);
GetDlgItem(EDIT_FILE_SEED)->EnableWindow(FALSE);
GetDlgItem(EDIT_RE_NAME)->EnableWindow(FALSE);
GetDlgItem(BTN_FILE_BROWSE)->EnableWindow(TRUE);
GetDlgItem(BTN_RE_BROWSE)->EnableWindow(FALSE);
CheckRadioButton(1020, 1028, 1027);
EnableDoiIt();
CCryptestApp* pcCryptest = (CCryptestApp*) AfxGetApp();
pcCryptest->m_nFSItemCnt = 0;
}
void CFileStffDlg::OnSecretShare()
{
m_nFileType = 8;
GetDlgItem(BTN_FILE_DOIT)->SetWindowText(_T("Share It"));
GetDlgItem(STATIC_FILE_INFO)->SetWindowText(_T("Secret share a file (shares will be named file.000, file.001, etc)"));
GetDlgItem(EDIT_FILE_NAME)->EnableWindow(TRUE);
GetDlgItem(EDIT_COMPRESSION_LEVEL)->EnableWindow(FALSE);
GetDlgItem(EDIT_NUM_SHARES)->EnableWindow(TRUE);
GetDlgItem(EDIT_THRESHOLD)->EnableWindow(TRUE);
GetDlgItem(EDIT_FILE_SEED)->EnableWindow(TRUE);
GetDlgItem(EDIT_RE_NAME)->EnableWindow(FALSE);
GetDlgItem(BTN_FILE_BROWSE)->EnableWindow(TRUE);
GetDlgItem(BTN_RE_BROWSE)->EnableWindow(FALSE);
CheckRadioButton(1020, 1028, 1022);
EnableDoiIt();
CCryptestApp* pcCryptest = (CCryptestApp*) AfxGetApp();
pcCryptest->m_nFSItemCnt = 0;
}
void CFileStffDlg::OnSecretShareRecontruct()
{
m_nFileType = 9;
GetDlgItem(BTN_FILE_DOIT)->SetWindowText(_T("Re-Share It"));
GetDlgItem(STATIC_FILE_INFO)->SetWindowText(_T("Reconstruct a secret-shared file"));
GetDlgItem(EDIT_FILE_NAME)->EnableWindow(FALSE);
GetDlgItem(EDIT_COMPRESSION_LEVEL)->EnableWindow(FALSE);
GetDlgItem(EDIT_NUM_SHARES)->EnableWindow(FALSE);
GetDlgItem(EDIT_THRESHOLD)->EnableWindow(TRUE);
GetDlgItem(EDIT_FILE_SEED)->EnableWindow(FALSE);
GetDlgItem(EDIT_RE_NAME)->EnableWindow(TRUE);
GetDlgItem(BTN_FILE_BROWSE)->EnableWindow(TRUE);
GetDlgItem(BTN_RE_BROWSE)->EnableWindow(TRUE);
CheckRadioButton(1020, 1028, 1023);
EnableDoiIt();
CCryptestApp* pcCryptest = (CCryptestApp*) AfxGetApp();
pcCryptest->m_nFSItemCnt = 0;
}
void CFileStffDlg::OnFileDoit()
{
CWaitCursor wait;
CCryptestApp* pcCryptest = (CCryptestApp*) AfxGetApp();
UpdateData(TRUE);
int n=0;
CString csFilePath = _T("");
char *inFile[1000];
m_lcFileStuff.DeleteAllItems();
pcCryptest->m_nFSItemCnt = 0;
switch (m_nFileType)
{
case 1:
if ((!m_csFileName.IsEmpty()) && ((m_csFileName.GetAt(1) == TCHAR(':')) || (m_csFileName.GetAt(1) == TCHAR('\\'))))
{
pcCryptest->DigestFile(m_csFileName);
GetDlgItem(EDIT_FILE_NAME)->SetWindowText(_T("Ready - Press the button to pick a file ==> "));
}
else
{
AfxMessageBox(_T("You MUST have a 'File Name'!"));
m_btnBrowse.SetFocus() ;
}
break;
case 2:
if ((!m_csFileName.IsEmpty()) && ((m_csFileName.GetAt(1) == TCHAR(':')) || (m_csFileName.GetAt(1) == TCHAR('\\'))))
{
pcCryptest->InformationDisperseFile(m_nThreshold, m_nNumShares, m_csFileName);
m_lcFileStuff.InsertItem(pcCryptest->m_nFSItemCnt, _T("Done..."));
GetDlgItem(EDIT_FILE_NAME)->SetWindowText(_T("Ready - Press the button to pick a file ==> "));
}
else
{
AfxMessageBox(_T("You MUST have a 'File Name'!"));
m_btnBrowse.SetFocus() ;
}
break;
case 3:
if (m_csaFiles.GetSize() > 1)
{
for (n=0; n<m_csaFiles.GetSize(); n++)
{
csFilePath = m_csaFiles.GetAt(n);
if (n==0)
m_csFileName = csFilePath.Left(csFilePath.ReverseFind(TCHAR('.')));
inFile[n] = new char [csFilePath.GetLength()];
sprintf(inFile[n], m_csaFiles.GetAt(n));
csFilePath = _T("");
}
pcCryptest->InformationRecoverFile(m_nThreshold, m_csFileName, inFile);
m_csaFiles.RemoveAll();
GetDlgItem(EDIT_RE_NAME)->SetWindowText(_T("Re-construct - Press the button to pick files ==> "));
m_lcFileStuff.InsertItem(pcCryptest->m_nFSItemCnt, _T("Done..."));
}
else
{
AfxMessageBox(_T("You MUST have some 'Re-Names'!"));
m_btnReBrowse.SetFocus() ;
}
break;
case 4:
if ((!m_csFileName.IsEmpty()) && ((m_csFileName.GetAt(1) == TCHAR(':')) || (m_csFileName.GetAt(1) == TCHAR('\\'))))
{
if (!m_csSeed.IsEmpty())
{
pcCryptest->EncryptFile(m_csFileName, m_csFileName + _T(".enc"), m_csSeed);
GetDlgItem(EDIT_FILE_NAME)->SetWindowText(_T("Ready - Press the button to pick a file ==> "));
}
else
{
AfxMessageBox(_T("You MUST have a 'Seed'!"));
m_edtFileSeed.SetFocus() ;
}
m_lcFileStuff.InsertItem(pcCryptest->m_nFSItemCnt, _T("Done..."));
}
else
{
AfxMessageBox(_T("You MUST have a 'File Name'!"));
m_btnBrowse.SetFocus() ;
}
break;
case 5:
if ((!m_csFileName.IsEmpty()) && ((m_csFileName.GetAt(1) == TCHAR(':')) || (m_csFileName.GetAt(1) == TCHAR('\\'))))
{
pcCryptest->DecryptFile(m_csFileName, m_csFileName.Left(m_csFileName.GetLength() - 4), m_csSeed);
m_lcFileStuff.InsertItem(pcCryptest->m_nFSItemCnt, _T("Done..."));
GetDlgItem(EDIT_FILE_NAME)->SetWindowText(_T("Ready - Press the button to pick a file ==> "));
}
else
{
AfxMessageBox(_T("You MUST have a 'File Name'!"));
m_btnBrowse.SetFocus() ;
}
break;
case 6:
if ((!m_csFileName.IsEmpty()) && ((m_csFileName.GetAt(1) == TCHAR(':')) || (m_csFileName.GetAt(1) == TCHAR('\\'))))
{
pcCryptest->GzipFile(m_csFileName, m_csFileName + _T(".gzip"), m_nCompLevel);
m_lcFileStuff.InsertItem(pcCryptest->m_nFSItemCnt, _T("Done..."));
GetDlgItem(EDIT_FILE_NAME)->SetWindowText(_T("Ready - Press the button to pick a file ==> "));
}
else
{
AfxMessageBox(_T("You MUST have a 'File Name'!"));
m_btnBrowse.SetFocus() ;
}
break;
case 7:
if ((!m_csFileName.IsEmpty()) && ((m_csFileName.GetAt(1) == TCHAR(':')) || (m_csFileName.GetAt(1) == TCHAR('\\'))))
{
pcCryptest->GunzipFile(m_csFileName, m_csFileName.Left(m_csFileName.GetLength() - 5));
m_lcFileStuff.InsertItem(pcCryptest->m_nFSItemCnt, _T("Done..."));
GetDlgItem(EDIT_FILE_NAME)->SetWindowText(_T("Ready - Press the button to pick a file ==> "));
}
else
{
AfxMessageBox(_T("You MUST have a 'File Name'!"));
m_btnBrowse.SetFocus() ;
}
break;
case 8:
if ((!m_csFileName.IsEmpty()) && ((m_csFileName.GetAt(1) == TCHAR(':')) || (m_csFileName.GetAt(1) == TCHAR('\\'))))
{
if (!m_csSeed.IsEmpty())
{
pcCryptest->SecretShareFile(m_nThreshold, m_nNumShares, m_csFileName, m_csSeed);
GetDlgItem(EDIT_FILE_NAME)->SetWindowText(_T("Ready - Press the button to pick a file ==> "));
}
else
{
AfxMessageBox(_T("You MUST have a 'Seed'!"));
m_edtFileSeed.SetFocus() ;
}
m_lcFileStuff.InsertItem(pcCryptest->m_nFSItemCnt, _T("Done..."));
}
else
{
AfxMessageBox(_T("You MUST have a 'File Name'!"));
m_btnBrowse.SetFocus() ;
}
break;
case 9:
if (m_csaFiles.GetSize() > 1)
{
for (n=0; n<m_csaFiles.GetSize(); n++)
{
csFilePath = m_csaFiles.GetAt(n);
if (n==0)
m_csFileName = csFilePath.Left(csFilePath.ReverseFind(TCHAR('.')));
inFile[n] = new char [csFilePath.GetLength()];
sprintf(inFile[n], m_csaFiles.GetAt(n));
csFilePath = _T("");
}
pcCryptest->SecretRecoverFile(m_nThreshold, m_csFileName, inFile);
m_csaFiles.RemoveAll();
GetDlgItem(EDIT_RE_NAME)->SetWindowText(_T("Re-construct - Press the button to pick files ==> "));
m_lcFileStuff.InsertItem(pcCryptest->m_nFSItemCnt, _T("Done..."));
}
else
{
AfxMessageBox(_T("You MUST have some 'Re-Names'!"));
m_btnReBrowse.SetFocus() ;
}
break;
}
}
void CFileStffDlg::OnChangeCompressionLevel()
{
UpdateData(TRUE);
if ((m_nCompLevel > 9) || (m_nCompLevel < 0))
AfxMessageBox(_T("You MUST have a 'Compression Level' between 0-9!"));
}
void CFileStffDlg::OnChangeNumShares()
{
UpdateData(TRUE);
if ((m_nNumShares > 999) || (m_nNumShares < 2))
AfxMessageBox(_T("You MUST have a '# of Shares' between 2-999!"));
}
void CFileStffDlg::OnChangeThreshold()
{
UpdateData(TRUE);
if ((m_nThreshold > 999) || (m_nThreshold < 2))
AfxMessageBox(_T("You MUST have a 'Threshold' between 2-999!"));
}