📄 main.cpp
字号:
/********** Hashish - Cross platform hasing utility *************/// --*-c++-*--/* Hashish - Cross platform hasing utility Copyright (C) 2003-2004 Jesse Lovelace, A. S. Logic Systems Co. jllovela@ncsu.edu 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 2 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/#include "wx/wx.h"#include "wx/app.h"#include "wx/frame.h"#include "wx/utils.h"#include "wx/menu.h"#include "wx/msgdlg.h"#include "wx/textdlg.h"#include "wx/listbox.h"#include "wx/filedlg.h"#include "wx/choicdlg.h"#include "wx/file.h"#if (!defined (__WXMAC__)) && (!defined (__WXX11__))#include "wx/dnd.h"#endif#include "wx/clipbrd.h"#ifdef WIN32#include "wx/msw/taskbar.h"#endif#include "hashish_wdr.h"/* cryptoPP includes */#include "cryptopp/misc.h"#include "cryptopp/files.h"#include "cryptopp/crc.h"#include "cryptopp/hex.h"#include "cryptopp/sha.h"#include "cryptopp/md2.h"#include "cryptopp/md5.h"#include "cryptopp/ripemd.h"#include "cryptopp/tiger.h"#include "cryptopp/base64.h"#include "cryptopp/panama.h"#include "cryptopp/haval.h"/* end cryptopp includes */#include "gnu_small_trans.xpm"#include <string>#include <stdexcept>using namespace std;using namespace CryptoPP;enum { ID_TASKBAR_EXIT = 19000, ID_TASKBAR_RESTORE, ID_TASKBAR_LOAD};class HashFrame;#ifdef WIN32class HashTaskBar: public wxTaskBarIcon{public: HashTaskBar() {} virtual void OnLButtonUp(wxEvent&); virtual void OnRButtonUp(wxEvent&); void OnLButtonDClick(wxEvent&); void OnMenuRestore(wxCommandEvent&); void OnMenuExit(wxCommandEvent&); void setFrame(HashFrame * frame) { m_frame = frame; }private: HashFrame * m_frame; DECLARE_EVENT_TABLE()};#endifclass MyApp : public wxApp{public: HashFrame * m_frame; virtual bool OnInit();#ifdef WIN32protected: HashTaskBar m_taskBarIcon;#endif};class HashFrame : public wxFrame{public:#if (!defined (__WXMAC__)) && (!defined (__WXX11__)) friend class DnDFile;#endif HashFrame(const wxString& title, const wxPoint& pos, const wxSize& size); void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); void OnBrowseFiles(wxCommandEvent& event); void OnChangeSource(wxCommandEvent& event); void OnHash(wxCommandEvent& event); void OnHex(wxCommandEvent& event); void On64(wxCommandEvent& event); void OnCopy(wxCommandEvent& event); void OnPaste(wxCommandEvent& event); void OnCut(wxCommandEvent& event); void OnClear(wxCommandEvent& event);private: bool m_hex; wxTextCtrl * m_filename; wxTextCtrl * m_string; wxTextCtrl * m_hashout; wxChoice * m_listhash; wxButton * m_browse; wxRadioBox * m_rbox; wxMenuBar * m_menu; DECLARE_EVENT_TABLE()};#if (!defined (__WXMAC__)) && (!defined (__WXX11__))class DnDFile : public wxFileDropTarget{public: DnDFile(HashFrame *pOwner) { m_pOwner = pOwner; } virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);private: HashFrame *m_pOwner;};bool DnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames){ // size_t nFiles = filenames.GetCount(); m_pOwner->m_filename->SetValue(filenames[0]); if ((m_pOwner->m_rbox->GetSelection() != 0)) return TRUE; wxCommandEvent myevent(wxEVT_COMMAND_BUTTON_CLICKED,ID_HASH); m_pOwner->ProcessEvent(myevent); return TRUE;}#endif //!WXMAC && !WXX11using namespace std;using namespace CryptoPP;IMPLEMENT_APP(MyApp)bool MyApp::OnInit(){ m_frame = new HashFrame(_T("Hashish"), wxDefaultPosition, wxSize(500, 140));#ifdef WIN32 wxIcon appIcon; appIcon.CopyFromBitmap(wxBitmap(gnu_small_trans_xpm)); m_taskBarIcon.SetIcon(appIcon, wxT("Hashish")); m_taskBarIcon.setFrame(m_frame);#endif m_frame->Show(TRUE); SetTopWindow(m_frame); return TRUE;}BEGIN_EVENT_TABLE(HashFrame, wxFrame) EVT_MENU(ID_MENU_QUIT, HashFrame::OnQuit) EVT_MENU(ID_MENU_OPEN, HashFrame::OnBrowseFiles) EVT_MENU(ID_MENU_HEX, HashFrame::OnHex) EVT_MENU(ID_MENU_64, HashFrame::On64) EVT_RADIOBOX(ID_HASH_SOURCE, HashFrame::OnChangeSource) EVT_BUTTON(ID_BUTTON_BROWSE, HashFrame::OnBrowseFiles) EVT_BUTTON(ID_HASH, HashFrame::OnHash) EVT_MENU(ID_TASKBAR_LOAD, HashFrame::OnBrowseFiles) EVT_MENU(ID_MENU_ABOUT, HashFrame::OnAbout) EVT_MENU(ID_MENU_EDIT_CUT, HashFrame::OnCut) EVT_MENU(ID_MENU_EDIT_PASTE, HashFrame::OnPaste) EVT_MENU(ID_MENU_EDIT_COPY, HashFrame::OnCopy) EVT_MENU(ID_MENU_EDIT_CLEAR, HashFrame::OnClear)END_EVENT_TABLE()HashFrame::HashFrame(const wxString& title, const wxPoint& pos, const wxSize& size) : wxFrame((wxFrame *)NULL, -1, title, pos, size, wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION){ wxIcon appIcon; appIcon.CopyFromBitmap(wxBitmap(gnu_small_trans_xpm)); SetIcon(appIcon); m_menu = MainMenu(); SetMenuBar(m_menu); CreateStatusBar(); wxPanel * pTopPanel = new wxPanel(this);#if (!defined __WXMAC__) && (!defined (__WXX11__)) pTopPanel->SetDropTarget(new DnDFile(this));#endif wxSizer * pPanelSizer = MainDiag(pTopPanel, true, true); pPanelSizer->SetSizeHints(this); SetSize(pPanelSizer->GetMinSize()); m_browse = (wxButton *)FindWindow(ID_BUTTON_BROWSE); m_filename = (wxTextCtrl *)FindWindow(ID_FILE_NAME); m_string = (wxTextCtrl *)FindWindow(ID_STRING); m_hashout = (wxTextCtrl *)FindWindow(ID_HASHOUT); m_listhash = (wxChoice *)FindWindow(ID_LIST_HASH); m_rbox = (wxRadioBox *)FindWindow(ID_HASH_SOURCE); m_hex = true; (m_menu->FindItem(ID_MENU_64))->Check(FALSE); (m_menu->FindItem(ID_MENU_HEX))->Check(TRUE); m_listhash->SetSelection(0); SetStatusText("Welcome to Hashish.");}void HashFrame::OnQuit(wxCommandEvent& event){ Close(TRUE);}void HashFrame::OnAbout(wxCommandEvent& WXUNUSED(event)){ wxMessageBox(_T("Hashish 1.1\n
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -