kolibrios/programs/other/TinyHashView/thashview.c

373 lines
14 KiB
C
Raw Normal View History

/* Copyright (C) 2019-2021 Logaev Maxim (turbocat2001), GPLv2 */
#include <sys/ksys.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <cryptal/md5.h>
#include <cryptal/sha1.h>
#include <cryptal/sha256.h>
#include <clayer/dialog.h>
#include <clayer/boxlib.h>
#define TRUE 1;
#define FALSE 0;
#define MAX_HASH_LEN 65 // <20><><EFBFBD><EFBFBD><E1A8AC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>
#define WINDOW_W 665
#define VERSION "%s - thashview 2.6.2"
#define EDIT_TEXT_SIZE 0x10000000
#define DATA(type, addr, offset) *((type*)((uint8_t*)addr+offset))
ksys_colors_table_t sys_color_table;
char hash_str_md5[MAX_HASH_LEN]= "Click the 'MD5:' button to show the md5-checksum!"; //<2F><EFBFBD> MD5
char hash_str_sha1[MAX_HASH_LEN]= "Click the 'SHA1:' button to show the sha1-checksum!"; //<2F><EFBFBD> SHA1
char hash_str_sha256[MAX_HASH_LEN]="Click the 'SHA256:' button to show the sha256-checksum!"; //<2F><EFBFBD> SHA256
char edit_box_buff[MAX_HASH_LEN]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
char *filename; // <20><><EFBFBD> <20><><EFBFBD><E0A0A1><EFBFBD><EBA2A0><EFBFBD><EFBFBD><EFBFBD><><E4A0A9>
char *title; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
enum MYCOLORS // <20><><EFBFBD><EFBFBD><EFBFBD>
{
GREEN = 0x067D06 | EDIT_TEXT_SIZE,
RED = 0xFF0000 | EDIT_TEXT_SIZE,
BLACK = 0x000000 | EDIT_TEXT_SIZE,
WHITE = 0xFFFFFF,
GREY = 0x919191
};
edit_box hash_edit_box={WINDOW_W-140,10,121,WHITE,0,0,GREY,EDIT_TEXT_SIZE, MAX_HASH_LEN-1, edit_box_buff,NULL,ed_focus}; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> edit_box
int md5_flag=0, sha1_flag=0, sha256_flag=0; // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><20><20><><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>஫쭠<E0AEAB> <20><EFBFBD> <20> <20>㭪樨 check_sum()
enum BUTTONS // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4A5A9>
{
BTN_QUIT=1, //<2F><>
BTN_MD5 = 10, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> md5-<2D><><EFBFBD><EFBFBD><EFBFBD><E0AEAB><EFBFBD><EFBFBD> <20><EFBFBD>
BTN_SHA1 = 20, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> sha1-<2D><><EFBFBD><EFBFBD><EFBFBD><E0AEAB><EFBFBD><EFBFBD> <20><EFBFBD>
BTN_SHA256 = 30, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> sha256-<2D><><EFBFBD><EFBFBD><EFBFBD><E0AEAB><EFBFBD><EFBFBD> <20><EFBFBD>
BTN_COPY_MD5= 11, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E0AEA2><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BTN_COPY_SHA1= 21,
BTN_COPY_SHA256=31,
BTN_CMP=40, //<2F><EFBFBD><E0A0A2><EFBFBD><EFBFBD> edit_box <20> <20><><EFBFBD><EFBFBD><EFBFBD><E0AEAB><EFBFBD><EFBFBD> <20><EFBFBD>
BTN_PASTE=50 //<2F><><EFBFBD><E2A0A2><EFBFBD> <20> edit_box(<28><><EFBFBD><EFBFBD> <20> ࠧࠡ<E0A0A7>⪥)
};
void notify_show(char *text)
{
_ksys_exec("/sys/@notify", text);
}
void* safe_malloc(size_t size) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> malloc. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBA2A0><><E3A2A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><EFBFBD><E8A8A1> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EBA2A0> <20>ணࠬ<E0AEA3><E0A0AC> <20><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><20><EFBFBD><EBA4A5><EFBFBD><EFBFBD>
{
void *p=malloc(size);
if(p==NULL){
notify_show("'Memory allocation error!' -E");
exit(0);
}else{
return p;
}
}
void global_var_init(unsigned int size) // <20><><EFBFBD><EFBFBD><E6A8A0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
{
filename=safe_malloc(size);
title=safe_malloc(size+20);
}
/* <20>㭪樨 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><E0AEAB><EFBFBD><EFBFBD> <20>㬬 */
void md5_hash(FILE* input, BYTE* hash )
{
int input_size;
BYTE *temp_buffer;
temp_buffer=safe_malloc(1024);
MD5_CTX ctx;
md5_init(&ctx);
while((input_size = fread(temp_buffer, 1, 1024, input)) > 0){
md5_update(&ctx, temp_buffer, input_size);
}
md5_final(&ctx, hash);
free(temp_buffer);
}
void sha1_hash(FILE* input, BYTE* hash )
{
int input_size;
BYTE *buffer;
buffer=safe_malloc(1024);
SHA1_CTX ctx;
sha1_init(&ctx);
while((input_size = fread(buffer, 1, 1024, input)) > 0){
sha1_update(&ctx, buffer, input_size);
}
sha1_final(&ctx, hash);
free(buffer);
}
void sha256_hash(FILE* input, BYTE* hash )
{
int input_size;
BYTE *buffer;
buffer=safe_malloc(1024);
SHA256_CTX ctx;
sha256_init(&ctx);
while((input_size = fread(buffer, 1, 1024, input)) > 0){
sha256_update(&ctx, buffer, input_size);
}
sha256_final(&ctx, hash);
free(buffer);
}
BYTE* check_sum(int alg) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><E0AEAB><EFBFBD><EFBFBD> <20><EFBFBD> <20><EFBFBD><E1AFAE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
FILE* input_file;
BYTE *hash;
input_file=fopen(filename,"rb");
hash = safe_malloc(alg);
switch (alg)
{
case MD5_BLOCK_SIZE :
md5_hash(input_file, hash);
md5_flag=1;
break;
case SHA1_BLOCK_SIZE :
sha1_hash(input_file, hash);
sha1_flag=1;
break;
case SHA256_BLOCK_SIZE :
sha256_hash(input_file, hash);
sha256_flag=1;
break;
}
fclose(input_file);
return hash;
}
void sprint_hash(BYTE *hash, char* hash_str, int hash_size) //<2F><EFBFBD><E0A5AE><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> hash <20> <20><><EFBFBD> hash_str
{
char block[3];
memset(hash_str, 0, MAX_HASH_LEN); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD> strcat
for(int i=0; i<hash_size; i++)
{
sprintf(block,"%02x", hash[i]);
strcat(hash_str,block);
}
free(hash);
}
void redraw_window() //<2F><><EFBFBD><20><><EFBFBD><EFBFBD>
{
sprintf(title,VERSION, filename); // <20><><EFBFBD><E2A0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
ksys_pos_t win_pos = _ksys_get_mouse_pos(KSYS_MOUSE_SCREEN_POS); // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><E0A4A8><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
_ksys_start_draw(); //<2F><><EFBFBD><E7A8AD><EFBFBD> <20><><EFBFBD><E1AEA2><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4A5A9> )
_ksys_create_window(win_pos.x, win_pos.y, WINDOW_W, 150, title, sys_color_table.work_area, 0x14); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
edit_box_draw(&hash_edit_box); // <20><><EFBFBD>㥬 edit_box
_ksys_define_button(10, 30, 60, 20, BTN_MD5, GREEN); // <20><><EFBFBD><E0A5A4><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> md5
_ksys_define_button(10, 60, 60, 20, BTN_SHA1, GREEN);// <20><><EFBFBD><E0A5A4><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> sha1
_ksys_define_button(10, 90, 60, 20, BTN_SHA256, GREEN);// <20><><EFBFBD><E0A5A4><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> sha256
_ksys_draw_text("MD5:", 15, 34, 0, 0x90000000 | sys_color_table.work_button_text); // <20><>饬 ⥪<><E2A5AA> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
_ksys_draw_text("SHA1:", 15, 64, 0, 0x90000000 | sys_color_table.work_button_text);
_ksys_draw_text("SHA256:", 15,94, 0, 0x90000000 | sys_color_table.work_button_text);
_ksys_draw_text(hash_str_md5, 80, 34, 0, 0x90000000 | sys_color_table.work_text); // <20><EFBFBD><EBA2AE><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><E0AEAB><EFBFBD><EFBFBD> <20><EFBFBD> <20> <20><><EFBFBD><EFBFBD>
_ksys_draw_text(hash_str_sha1, 80, 64, 0, 0x90000000 | sys_color_table.work_text);
_ksys_draw_text(hash_str_sha256, 80, 94, 0, 0x90000000| sys_color_table.work_text);
_ksys_define_button(610, 30, 42, 20, BTN_COPY_MD5, sys_color_table.work_button); // <20><><EFBFBD><E0A5A4><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><E0AEA2><EFBFBD><EFBFBD>
_ksys_define_button(610, 60, 42, 20, BTN_COPY_SHA1, sys_color_table.work_button);
_ksys_define_button(610, 90, 42, 20, BTN_COPY_SHA256, sys_color_table.work_button);
_ksys_draw_text("Copy", 615, 34, 0, 0x90000000 | sys_color_table.work_button_text); // <20><>襬 copy <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><E0AEA2><EFBFBD><EFBFBD>
_ksys_draw_text("Copy", 615, 64, 0, 0x90000000 | sys_color_table.work_button_text);
_ksys_draw_text("Copy", 615, 94, 0, 0x90000000 | sys_color_table.work_button_text);
_ksys_define_button(592, 120, 60, 20, BTN_CMP, GREEN); // <20><><EFBFBD><E0A5A4><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><EFBFBD><E0A0A2><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><E2AEAB><EFBFBD><EFBFBD> <20>
_ksys_draw_text("Compare", 595, 124 , 0,0x90000000 | sys_color_table.work_button_text); // <20><>襬 ⥪<> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
_ksys_define_button(540, 120, 45, 20, BTN_PASTE, sys_color_table.work_button); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><E2A0A2> (<28><><EFBFBD><EFBFBD>)
_ksys_draw_text("Paste", 543, 124 , 0,0x90000000 | sys_color_table.work_button_text); // <20><><EFBFBD><EFBFBD><EFBFBD> paste <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
_ksys_end_draw();
}
void paste_to_edit_buffer() // <20><><EFBFBD><E2A0A2><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
char *temp_buff=NULL;
if(_ksys_clip_num()>0){
temp_buff=_ksys_clip_get(_ksys_clip_num()-1);
memset(edit_box_buff,0,MAX_HASH_LEN);
if(DATA(int, temp_buff,0)>0 && DATA(int,temp_buff,4)==KSYS_CLIP_TEXT && DATA(int,temp_buff,8)==KSYS_CLIP_CP866){
strncpy(edit_box_buff,temp_buff+12, MAX_HASH_LEN-1);
edit_box_set_text(&hash_edit_box,edit_box_buff);
notify_show("'Pasted from clipboard!' -I");
hash_edit_box.text_color = BLACK;
free(temp_buff);
}
}
}
void copy_to_clipboard(char *text) // <20><><EFBFBD><EFBFBD><EFBFBD><E0AEA2><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
int text_hash_len = strlen(text)/2;
if(text_hash_len==MD5_BLOCK_SIZE ||
text_hash_len==SHA1_BLOCK_SIZE ||
text_hash_len==SHA256_BLOCK_SIZE) // <20>᫨ ⥪<><E2A5AA><><EFA2AB><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>-<2D><><EFBFBD><E0AEAA>
{
char *temp_buffer=safe_malloc(MAX_HASH_LEN+12); // <20><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><EFBFBD><E0A5AC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
memset(temp_buffer, 0, MAX_HASH_LEN); // <20><><EFBFBD><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD>
DATA(char,temp_buffer,4)=KSYS_CLIP_TEXT; // <20><><EFBFBD><E2A0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TEXT <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><E9A5AD> 4 <20><><EFBFBD><EFBFBD><EFBFBD>)
DATA(char,temp_buffer,8)=KSYS_CLIP_CP866; // <20><><EFBFBD><E2A0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><E0AEA2> CP866(<28><><EFBFBD><EFBFBD><E9A5AD> 8 <20><><EFBFBD><EFBFBD>)
strncpy(temp_buffer+12, text, MAX_HASH_LEN-1); // <20><><EFBFBD><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> text <20><> <20><EFBFBD><E0A5AC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><E9A5AD> 12 <20><><EFBFBD><EFBFBD>)
_ksys_clip_set(strlen(text)+12, temp_buffer); // <20><EFBFBD><EBAFAE><20><><EFBFBD><EFBFBD><E2A5AC><EFBFBD> <20><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><EFBFBD><E0A5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
notify_show("'Copied to clipboard!' -I");
free(temp_buffer); // <20><EFBFBD><E1A2AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><E0A5AC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>.
}
}
void print_pending_calc(char *str) // <20><EFBFBD><EBA2AE><EFBFBD><><EFBFBD><E9A5AD> <20><20><><EFBFBD> <20><><EFBFBD><EFBFBD>஫쭠<E0AEAB> <20><EFBFBD><E3ACAC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
{
strcpy(str, "Please wait! Calculating checksum...");
redraw_window();
}
bool calc_and_cmp(char *hash_str_universal,int alg) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><E0AEAB><EFBFBD><EFBFBD> <20><EFBFBD> <20> <20><EFBFBD><E0A0A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> edit_box_buff.
{
print_pending_calc(hash_str_universal);
sprint_hash(check_sum(alg),hash_str_universal, alg);
return !strcmp(edit_box_buff, hash_str_universal);
}
bool hash_compare() // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><E3ADAA><EFBFBD> <20><><EFBFBD> <20><EFBFBD><E0A0A2><EFBFBD><EFBFBD><EFBFBD>
{
int alg=strlen(edit_box_buff)/2;
switch (alg){ // <20><20><><EFBFBD><EFBFBD><EFBFBD><E1ABA5><EFBFBD> <20><><EFBFBD> <20><><EFBFBD>
case MD5_BLOCK_SIZE:
if(md5_flag){
return !strcmp(edit_box_buff,hash_str_md5);
}else{
return calc_and_cmp(hash_str_md5,alg);
}
break;
case SHA1_BLOCK_SIZE:
if(sha1_flag){
return !strcmp(edit_box_buff,hash_str_sha1);
}else{
return calc_and_cmp(hash_str_sha1,alg);
}
break;
case SHA256_BLOCK_SIZE:
if(sha256_flag){
return !strcmp(edit_box_buff,hash_str_sha256);
}else{
return calc_and_cmp(hash_str_sha256,alg);
}
break;
default:
return FALSE;
break;
}
}
int main(int argc, char** argv)
{
kolibri_boxlib_init(); // <20><><EFBFBD><EFBFBD><EFBFBD><E3A6A0> boxlib
if(argc<2){ // <20><20><><EFBFBD><EFBFBD><20><><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><E1AAA0> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><EBA1AE> <20><>
kolibri_dialog_init(); // <20><><EFBFBD><EFBFBD><EFBFBD><E3A6A0> proc_lib(libdialog)
open_dialog* dialog = kolibri_new_open_dialog(OPEN,0, 0, 420, 320);
OpenDialog_init(dialog);
OpenDialog_start(dialog);
if(dialog->status==SUCCESS){ // <20>᫨ 䠩<> <20><><EFBFBD>
global_var_init(strlen(dialog->openfile_path));
strcpy(filename, dialog->openfile_path);
}else{ // <20>᫨ 䠩<> <20><> <20><><EFBFBD>
notify_show("'No file selected!' -E");
exit(0);
}
free(dialog);
}else{
global_var_init(strlen(argv[1]));
strcpy(filename, argv[1]);
}
if(NULL==fopen(filename,"rb")){ // <20>᫨ 䠩<><E4A0A9> <20><><EFBFBD> <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EBA2A0><EFBFBD><EFBFBD>
notify_show("'File not found!' -E");
exit(0);
}
if(_ksys_screen_size().x<WINDOW_W){
notify_show("'Low screen resolution! Program will not display correctrly!' -W");
}
int gui_event; // <20><><EFBFBD><E0A5AC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><EFBFBD><E0A0AD><EFBFBD><EFBFBD><><E1AEA1><EFBFBD><EFBFBD>
uint32_t pressed_button = 0; // <20><><EFBFBD> <20><><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>
_ksys_get_system_colors(&sys_color_table);
hash_edit_box.shift_color=sys_color_table.work_button;
_ksys_set_event_mask(0xC0000027);// <20><><EFBFBD><E2A0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><>
do // <20><><EFBFBD><EFBFBD> <20><><EFBFBD>⪨ ᮡ<>
{
gui_event = _ksys_get_event(); // <20><><EFBFBD><EFBFBD><EFBFBD><>
switch(gui_event){ // <20><><EFBFBD><E0A0A1><EFBFBD><EBA2A0><><E1AEA1><EFBFBD><EFBFBD>
case KSYS_EVENT_NONE:
break;
case KSYS_EVENT_REDRAW:
redraw_window();
break;
case KSYS_EVENT_MOUSE:
edit_box_mouse(&hash_edit_box);
break;
case KSYS_EVENT_KEY:
hash_edit_box.text_color = BLACK;
edit_box_key(&hash_edit_box, _ksys_get_key().val);
break;
case KSYS_EVENT_BUTTON: // <20><><EFBFBD><EFBFBD><20><><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pressed_button = _ksys_get_button(); // <20><><EFBFBD><EFBFBD><EFBFBD><E7A5AD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
switch (pressed_button){ // <20><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
case BTN_MD5:
print_pending_calc(hash_str_md5);
sprint_hash(check_sum(MD5_BLOCK_SIZE),hash_str_md5, MD5_BLOCK_SIZE);
break;
case BTN_SHA1:
print_pending_calc(hash_str_sha1);
sprint_hash(check_sum(SHA1_BLOCK_SIZE),hash_str_sha1, SHA1_BLOCK_SIZE);
break;
case BTN_SHA256:
print_pending_calc(hash_str_sha256);
sprint_hash(check_sum(SHA256_BLOCK_SIZE),hash_str_sha256, SHA256_BLOCK_SIZE);
break;
case BTN_COPY_MD5:
copy_to_clipboard(hash_str_md5);
break;
case BTN_COPY_SHA1:
copy_to_clipboard(hash_str_sha1);
break;
case BTN_COPY_SHA256:
copy_to_clipboard(hash_str_sha256);
break;
case BTN_PASTE:
paste_to_edit_buffer();
break;
case BTN_CMP:
if(hash_compare()){
notify_show("'The checksum matches :)' -OK");
hash_edit_box.text_color = GREEN; // <20><><EFBFBD><E2A0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><E2A5AA> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><20><><EFBFBD><EFBFBD>஫쭠<E0AEAB> <20><EFBFBD><><E1AEA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}else{
notify_show("'The checksum does not match! :(' -W");
hash_edit_box.text_color = RED; // <20><><EFBFBD><E2A0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><E2A5AA> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><20><><EFBFBD><EFBFBD>஫쭠<E0AEAB> <20><EFBFBD> <20><><><E1AEA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
break;
case BTN_QUIT:
exit(0);
break;
}
redraw_window();
break;
}
}while(1);
return 0;
}