Commit 6c0691d4 authored by Marek Gera's avatar Marek Gera
Browse files

Update bmp.c

parent 0a65349c
......@@ -6,7 +6,7 @@
#include "bmp.h"
unsigned char* bit_encrypt(const char* text){
if(text==NULL)
if(text==NULL || strlen(text)==0)
return NULL;
unsigned char* desttext = (unsigned char*)calloc(strlen(text)+1,sizeof(char));
for(int i=0;i<strlen(text);i++){
......@@ -63,7 +63,7 @@ unsigned char* bit_encrypt(const char* text){
}
char* bit_decrypt(const unsigned char* text){
if(text==NULL)
if(text==NULL || strlen(text)==0)
return NULL;
char* pole = (char*)calloc(strlen((char*)text)+1,sizeof(char));
int z=0;
......@@ -108,7 +108,7 @@ do{
}
unsigned char* bmp_encrypt(const char* key, const char* text){
if(key==NULL || text==NULL)
if(key==NULL || text==NULL || strlen(text)==0 || strlen(key)==0)
return NULL;
for(int i=0;i<strlen(key);i++){
if(!isalpha(key[i]))
......@@ -123,7 +123,7 @@ unsigned char* bmp_encrypt(const char* key, const char* text){
}
char* bmp_decrypt(const char* key, const unsigned char* text){
if(key==NULL || text==NULL)
if(key==NULL || text==NULL || strlen(text)==0 || strlen(key)==0)
return NULL;
if(key[0]=='\0' || text[0]=='\0')
return NULL;
......@@ -138,7 +138,7 @@ char* bmp_decrypt(const char* key, const unsigned char* text){
}
char* reverse(const char* text){
if(text == NULL){
if(text == NULL || strlen(text)==0){
return NULL;
}
int len=(int)strlen(text);
......@@ -159,7 +159,7 @@ char* reverse(const char* text){
}
char* vigenere_encrypt(const char* key, const char* text){
if(key==NULL || text==NULL)
if(key==NULL || text==NULL || strlen(text)==0 || strlen(key)==0)
return NULL;
for(int i=0;i<strlen(key);i++){
if(!isalpha(key[i]))
......@@ -208,7 +208,7 @@ char* vigenere_encrypt(const char* key, const char* text){
}
char* vigenere_decrypt(const char* key, const char* text){
if(key==NULL || text==NULL)
if(key==NULL || text==NULL || strlen(text)==0 || strlen(key)==0)
return NULL;
for(int i=0;i<strlen(key);i++){
if(!isalpha(key[i]))
......
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