2020-09-21 20:37:22 +03:00
|
|
|
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ᨬ(turbocat2001) */
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include "kos32sys.h"
|
|
|
|
|
#include "notify.h"
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
#include "algorithms/md5.h"
|
|
|
|
|
#include "algorithms/sha1.h"
|
|
|
|
|
#include "algorithms/sha256.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
|
2020-11-24 17:40:29 +03:00
|
|
|
|
#define VERSION "%s - thashview 2.3"
|
2020-09-21 20:37:22 +03:00
|
|
|
|
|
|
|
|
|
typedef unsigned char bool;
|
|
|
|
|
struct kolibri_system_colors sys_color_table;
|
|
|
|
|
|
|
|
|
|
char hex[]={"abcdefABCDEF1234567890"}; //<2F><><EFBFBD> <20><EFBFBD>ન <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᨬ<><E1A8AC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
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 = 0x00067D06,
|
|
|
|
|
RED = 0x00FF0000,
|
|
|
|
|
BLACK = 0x00000000,
|
|
|
|
|
WHITE = 0xFFFFFFFF,
|
|
|
|
|
GREY = 0x00DDD7CF
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int str_pos=0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><>ப<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
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()
|
|
|
|
|
int edit_box_text_color=BLACK; // <20><><EFBFBD><EFBFBD>砫<EFBFBD><E7A0AB><EFBFBD><EFBFBD> 梥<> ⥪<><E2A5AA><EFBFBD> <20> <20><>ப<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
enum MYKEYS // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
CTRL_V=22,
|
|
|
|
|
BACKSPACE=8
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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* 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>
|
|
|
|
|
{
|
|
|
|
|
pos_t win_pos = get_mouse_pos(0); //<2F><><EFBFBD><EFBFBD>砥<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><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>
|
|
|
|
|
begin_draw(); //<2F><>稭<EFBFBD><E7A8AD><EFBFBD> <20><>ᮢ<EFBFBD><E1AEA2><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>䥩<EFBFBD><E4A5A9> )
|
2020-11-24 17:40:29 +03:00
|
|
|
|
sys_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>.
|
2020-09-21 20:37:22 +03:00
|
|
|
|
|
|
|
|
|
draw_bar(10, 121, 525,20, WHITE); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>אַ㣮<EFACAE>쭨<EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
draw_text_sys(edit_box_buff,15, 125, 0, 0x90000000| edit_box_text_color); // <20>뢮<EFBFBD><EBA2AE><EFBFBD> ⥪<><E2A5AA> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
draw_text_sys("|",10+(8*str_pos),125,0,0x90000000 | sys_color_table.work_text);
|
|
|
|
|
|
|
|
|
|
define_button((10 << 16) + 60, (30 << 16) + 20, BTN_MD5, GREEN); // <20><>।<EFBFBD><E0A5A4>塞 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> md5
|
|
|
|
|
define_button((10 << 16) + 60, (60 << 16) + 20, BTN_SHA1, GREEN);// <20><>।<EFBFBD><E0A5A4>塞 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> sha1
|
|
|
|
|
define_button((10 << 16) + 60, (90 << 16) + 20, BTN_SHA256, GREEN);// <20><>।<EFBFBD><E0A5A4>塞 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> sha256
|
|
|
|
|
|
|
|
|
|
draw_text_sys("MD5:", 15, 34, 0, 0x90000000 | sys_color_table.work_button_text); // <20><>饬 ⥪<><E2A5AA> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
draw_text_sys("SHA1:", 15, 64, 0, 0x90000000 | sys_color_table.work_button_text);
|
|
|
|
|
draw_text_sys("SHA256:", 15,94, 0, 0x90000000 | sys_color_table.work_button_text);
|
|
|
|
|
|
|
|
|
|
draw_text_sys(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>
|
|
|
|
|
draw_text_sys(hash_str_sha1, 80, 64, 0, 0x90000000 | sys_color_table.work_text);
|
|
|
|
|
draw_text_sys(hash_str_sha256, 80, 94, 0, 0x90000000| sys_color_table.work_text);
|
|
|
|
|
|
|
|
|
|
define_button((610 << 16) + 42, (30 << 16) + 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>
|
|
|
|
|
define_button((610<< 16) + 42, (60 << 16) + 20, BTN_COPY_SHA1, sys_color_table.work_button);
|
|
|
|
|
define_button((610<< 16) + 42, (90 << 16) + 20, BTN_COPY_SHA256, sys_color_table.work_button);
|
|
|
|
|
|
|
|
|
|
draw_text_sys("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>
|
|
|
|
|
draw_text_sys("Copy", 615, 64, 0, 0x90000000 | sys_color_table.work_button_text);
|
|
|
|
|
draw_text_sys("Copy", 615, 94, 0, 0x90000000 | sys_color_table.work_button_text);
|
|
|
|
|
|
|
|
|
|
define_button((592<< 16) + 60, (120 << 16) + 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>㬬
|
|
|
|
|
draw_text_sys("Compare", 595, 124 , 0,0x90000000 | sys_color_table.work_button_text); // <20><>襬 ⥪<> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|
|
|
|
|
|
|
|
|
define_button((540 << 16) + 45, (120 << 16) + 20, BTN_PASTE, sys_color_table.work_button); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><>⠢<EFBFBD><E2A0A2> (<28><>ࠡ<EFBFBD>⠥<EFBFBD>)
|
|
|
|
|
draw_text_sys("Paste", 543, 124 , 0,0x90000000 | sys_color_table.work_button_text); // <20><><EFBFBD><EFBFBD><EFBFBD> paste <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
end_draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void paste_to_edit_buffer() // <20><>⠢<EFBFBD><E2A0A2><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
2020-11-24 17:40:29 +03:00
|
|
|
|
char *temp_buff=NULL;
|
|
|
|
|
if(kol_clip_num()>0)
|
2020-09-21 20:37:22 +03:00
|
|
|
|
{
|
2020-11-24 17:40:29 +03:00
|
|
|
|
temp_buff=kol_clip_get(kol_clip_num()-1);
|
|
|
|
|
memset(edit_box_buff,0,MAX_HASH_LEN);
|
|
|
|
|
if(((int)*(temp_buff)>0) && ((int)*(temp_buff+4)==0) && ((int)*(temp_buff+8)==1))
|
|
|
|
|
{
|
|
|
|
|
strncpy(edit_box_buff,temp_buff+12, MAX_HASH_LEN-1);
|
|
|
|
|
str_pos=strlen(edit_box_buff);
|
|
|
|
|
notify_show("'Pasted from clipboard!' -I");
|
|
|
|
|
edit_box_text_color=BLACK;
|
|
|
|
|
user_free(temp_buff);
|
|
|
|
|
|
|
|
|
|
}
|
2020-09-21 20:37:22 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void copy_to_clipboard(char *text) // <20><><EFBFBD><EFBFBD>ૢ<EFBFBD><E0ABA2><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(55!=strlen(text))
|
|
|
|
|
{
|
|
|
|
|
char *temp_buffer=safe_malloc(MAX_HASH_LEN+12);
|
|
|
|
|
memset(temp_buffer, 0, MAX_HASH_LEN);
|
|
|
|
|
*(temp_buffer+4)=0;
|
|
|
|
|
*(temp_buffer+8)=1;
|
|
|
|
|
strncpy(temp_buffer+12, text, MAX_HASH_LEN-1);
|
|
|
|
|
kol_clip_set(strlen(text)+12, temp_buffer);
|
|
|
|
|
notify_show("'Copied to clipboard!' -I");
|
|
|
|
|
free(temp_buffer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void edit_box(oskey_t key) //<2F>㭪<EFBFBD><E3ADAA><EFBFBD> ॠ<><E0A5A0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ப<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
2020-11-24 17:40:29 +03:00
|
|
|
|
edit_box_text_color=sys_color_table.frame_area;
|
2020-09-21 20:37:22 +03:00
|
|
|
|
if(key.code==CTRL_V) // <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ctrl+V <20><> <20><>⠢<EFBFBD><E2A0A2><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
paste_to_edit_buffer();
|
|
|
|
|
}
|
|
|
|
|
if(key.code==BACKSPACE && str_pos>0) // <20> backspace <20><> 㤠<><E3A4A0><EFBFBD><EFBFBD> <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD> ᨬ<><E1A8AC><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
str_pos--;
|
|
|
|
|
edit_box_buff[str_pos]='\0';
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(str_pos<MAX_HASH_LEN-1) // <20><>࠭<EFBFBD>祭<EFBFBD><E7A5AD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(strchr(hex,key.code)!=NULL)
|
|
|
|
|
{
|
|
|
|
|
edit_box_buff[str_pos]=key.code;
|
|
|
|
|
str_pos++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>砥<EFBFBD> <20><><EFBFBD> 䠩<><E4A0A9>
|
|
|
|
|
if(argc<2) // <20> <20><><EFBFBD>㬥<EFBFBD>⮢ <20><><EFBFBD> <20><> ᮮ<>頥<EFBFBD> <20><> <20>⮬
|
|
|
|
|
{
|
|
|
|
|
notify_show("'No file selected!' -E");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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(GetScreenSize()/65536<WINDOW_W)
|
|
|
|
|
{
|
|
|
|
|
notify_show("'Low screen resolution! Program will not display correctrly!' -W");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int gui_event; // <20><>६<EFBFBD><E0A5AC><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>
|
|
|
|
|
|
|
|
|
|
get_system_colors(&sys_color_table);
|
|
|
|
|
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 = get_os_event(); // <20><><EFBFBD><EFBFBD>砥<EFBFBD> ᮡ<>⨥
|
|
|
|
|
switch(gui_event) // <20><>ࠡ<EFBFBD><E0A0A1>뢠<EFBFBD><EBA2A0> ᮡ<><E1AEA1><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
case KOLIBRI_EVENT_NONE:
|
|
|
|
|
break;
|
|
|
|
|
case KOLIBRI_EVENT_REDRAW:
|
|
|
|
|
redraw_window();
|
|
|
|
|
break;
|
|
|
|
|
case KOLIBRI_EVENT_KEY:
|
|
|
|
|
edit_box(get_key()); // <20><><EFBFBD><EFBFBD>砥<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㥬 <20><>ப<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
redraw_window();
|
|
|
|
|
break;
|
|
|
|
|
case KOLIBRI_EVENT_BUTTON: // <20><><EFBFBD><EFBFBD>⨥ <20><>ࠡ<EFBFBD>⪨ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
pressed_button = get_os_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);
|
|
|
|
|
redraw_window();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BTN_SHA1:
|
|
|
|
|
print_pending_calc(hash_str_sha1);
|
|
|
|
|
sprint_hash(check_sum(SHA1_BLOCK_SIZE),hash_str_sha1, SHA1_BLOCK_SIZE);
|
|
|
|
|
redraw_window();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BTN_SHA256:
|
|
|
|
|
print_pending_calc(hash_str_sha256);
|
|
|
|
|
sprint_hash(check_sum(SHA256_BLOCK_SIZE),hash_str_sha256, SHA256_BLOCK_SIZE);
|
|
|
|
|
redraw_window();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BTN_COPY_MD5:
|
|
|
|
|
redraw_window();
|
|
|
|
|
copy_to_clipboard(hash_str_md5);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BTN_COPY_SHA1:
|
|
|
|
|
redraw_window();
|
|
|
|
|
copy_to_clipboard(hash_str_sha1);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BTN_COPY_SHA256:
|
|
|
|
|
redraw_window();
|
|
|
|
|
copy_to_clipboard(hash_str_sha256);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BTN_PASTE:
|
|
|
|
|
paste_to_edit_buffer();
|
|
|
|
|
redraw_window();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BTN_CMP:
|
|
|
|
|
if(hash_compare())
|
|
|
|
|
{
|
|
|
|
|
notify_show("'The checksum matches :)' -OK");
|
|
|
|
|
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");
|
|
|
|
|
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>
|
|
|
|
|
}
|
|
|
|
|
redraw_window();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BTN_QUIT:
|
|
|
|
|
exit(0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}while(1);
|
|
|
|
|
}
|