Commit 0a65349c authored by Marek Gera's avatar Marek Gera
Browse files

úprava zarovnania riadkov, medzier a komentárov.

parent 193a5ab1
......@@ -12,21 +12,20 @@ unsigned char* bit_encrypt(const char* text){
for(int i=0;i<strlen(text);i++){
desttext[i]=text[i];
}
// prepisanie znaku do dvojkovej sustavy
// prepisanie znaku do dvojkovej sustavy
int z=0;
do{
int new[8]={0};
do{
int new[8]={0};
char new1_tmp;
//for(int i=0; i<strlen((char*)desttext);i++){
char tmp=text[z];
int j=0;
do{
do{
new1_tmp=tmp%2;
new[j]=(int)new1_tmp;
tmp=tmp/2;
j++;
}while((int)tmp!=0);
// }
}while((int)tmp!=0);
for(int i=0;i<4;i++){
int o=new[i];
new[i]=new[7-i];
......@@ -56,21 +55,13 @@ do{
super=super+new[i]*mocnina;
}
/* for(int i=0; i<8;i++){
printf("%d",new[i]);
}
printf("\n");
printf("%d\n", super);
*/
desttext[z]=super;
z++;
}while(z<strlen(text));
return desttext;
}
char* bit_decrypt(const unsigned char* text){
if(text==NULL)
return NULL;
......@@ -115,6 +106,7 @@ do{
pole[strlen((char*)text)]='\0';
return pole;
}
unsigned char* bmp_encrypt(const char* key, const char* text){
if(key==NULL || text==NULL)
return NULL;
......@@ -129,6 +121,7 @@ unsigned char* bmp_encrypt(const char* key, const char* text){
free(bmp_vigenere);bmp_vigenere=NULL;
return bmp_bit_encrypt;
}
char* bmp_decrypt(const char* key, const unsigned char* text){
if(key==NULL || text==NULL)
return NULL;
......@@ -139,18 +132,11 @@ char* bmp_decrypt(const char* key, const unsigned char* text){
return NULL;
}
unsigned char* text1=(unsigned char*)text;
char* help = (char*)calloc(strlen((char*)text1)+1,sizeof(char));
// char* bmp_bit = bit_decrypt(text);
// char* bmp_vigenere = vigenere_decrypt(key, bmp_bit);
// char* bmp_reverse = reverse(bmp_vigenere);
// free(bmp_bit);bmp_bit=NULL;
// free(bmp_vigenere);bmp_vigenere=NULL;
// return bmp_reverse;
char* help = (char*)calloc(strlen((char*)text1)+1,sizeof(char));
return help;
}
char* reverse(const char* text){
if(text == NULL){
return NULL;
......@@ -171,6 +157,7 @@ char* reverse(const char* text){
return help;
}
char* vigenere_encrypt(const char* key, const char* text){
if(key==NULL || text==NULL)
return NULL;
......@@ -206,14 +193,10 @@ char* vigenere_encrypt(const char* key, const char* text){
}
}
destkey[strlen(text)]='\0';
/* printf("%d\n",strlen(destkey));
printf("%s\n",destkey);
printf("%d\n",strlen(desttext));
printf("%s\n",desttext);
*/
for( int j=0;j<strlen(text); j++ ){
if(!isalpha(desttext[j])){
j++;
j++;
}
desttext[j] = 'A' + (((desttext[j] -'A') + ((destkey[j])-'A')) % 26);
}
......@@ -223,6 +206,7 @@ char* vigenere_encrypt(const char* key, const char* text){
destkey=NULL;
return desttext;
}
char* vigenere_decrypt(const char* key, const char* text){
if(key==NULL || text==NULL)
return NULL;
......@@ -257,11 +241,7 @@ char* vigenere_decrypt(const char* key, const char* text){
}
}
destkey[strlen(text)]='\0';
/* printf("%d\n",strlen(destkey));
printf("%s\n",destkey);
printf("%d\n",strlen(desttext));
printf("%s\n",desttext);
*/
for( int j=0;j<strlen(text); j++ ){
if(!isalpha(desttext[j])){
j++;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment