...

View Full Version : what's wrong with this code ??



BISKOT188
11-22-2008, 04:10 PM
#include <stdio.h>
#include <string.h>
#include <conio.h>

char text[256];
int m,k,c,men;

/*Encrypt*/
void cez(char *Text)
{
printf("%s\n", "vvedite isxodniy text ");
gets(Text);
printf("%s\n", "vvedite klu4 shifrovani9 ");
scanf("%d", &k);

for(m = 0; m < strlen(text); ++m)
{
c = text[m] + k;
if(c > 256) c -= 256;
Text[m] = c;
}
}

/*Decrypt*/
void desh(char *Text)
{
printf("%s\n", "vvedite klu4 deshifrovki");
scanf("%d", &k);

for(m = 0; m < strlen(text); ++m)
{
c = Text[m] - k;
if(c < 256) c+=256;
Text[m] = c;
}
}
int main()
{
cez(text);
printf("%s\n", text);

desh(text);
printf("%s\n", text);

_getch();
return 0;
} i cant understand whats the problem when i put the letter o it doesnt give a know letter for some reason..:(((

oesxyl
11-22-2008, 04:19 PM
#include <stdio.h>
#include <string.h>
#include <conio.h>

char text[256];
int m,k,c,men;

/*Encrypt*/
void cez(char *Text)
{
printf("%s\n", "vvedite isxodniy text ");
gets(Text);
printf("%s\n", "vvedite klu4 shifrovani9 ");
scanf("%d", &k);

for(m = 0; m < strlen(text); ++m)
{
c = text[m] + k;
if(c > 256) c -= 256;
Text[m] = c;
}
}

/*Decrypt*/
void desh(char *Text)
{
printf("%s\n", "vvedite klu4 deshifrovki");
scanf("%d", &k);

for(m = 0; m < strlen(text); ++m)
{
c = Text[m] - k;
if(c < 256) c+=256;
Text[m] = c;
}
}
int main()
{
cez(text);
printf("%s\n", text);

desh(text);
printf("%s\n", text);

_getch();
return 0;
} i cant understand whats the problem when i put the letter o it doesnt give a know letter for some reason..:(((
- the code tags are [ code] and [ /code] not < code> and < /code>
- when you use 'o' or any letter after it will shift outside of printable chars. see ASCII for details.

regards

BISKOT188
11-23-2008, 08:53 AM
ox ok sorry well i also figure this out but i have no idea about the solution how to make that work and now shift in unknown chars any ideas?

oesxyl
11-23-2008, 03:23 PM
ox ok sorry well i also figure this out but i have no idea about the solution how to make that work and now shift in unknown chars any ideas?
check the result. There are few solution, search for ischar, isprint, isgraph, isascii, or do numeric tests like:


if(c < 127 && c > 'a')


I'm sorry this seems to be homework, I can give you some direction but that's all, read the forum rules about that.

regards

BISKOT188
11-23-2008, 07:54 PM
no it is not homework it s just a try to understand c language ..mate i ve done this same code in 3 languages ...if you dont beleive i can show you down but in that i didnt have to owercome with that ascii problem whitch appears to me in c...and i have no idea how to turn this out ...

this was my first code in pascal..


program shfrovalka;
uses crt;
var text:string;
m,k,c,men:integer;
procedure cez(var text:string; var k:integer);
begin
clrscr;
writeln('vvedite isxodniy text ');
write('$~/> ');
read(text);
write('vvedite klu4 shifrovani9 ');
readln(k);
for m:=1 to length(text) do
begin
c:=ord(text[m])+k;
if c>256 then c:=c-256;
text[m]:=chr(c);
end;
end;
procedure desh (var text:string);
begin
writeln('vvedite kluch deshifrovki' );
readln(k);
for m:=1 to length(text) do
begin
c:=ord(text[m])-k;
if c<256 then c:=c+256;
text[m]:=chr(c);
end;
end;
begin
repeat
clrscr;
writeln('1 - shifrovka ');
writeln('2 - deshifrovka ');
writeln('3 - sosto9nie texta ');
readln(men);
case men of
1:cez(text,k);
2:desh(text); U?
3:begin
writeln(text);
readkey;
end;
end;
until men = 0;
end.

this was in c++


#include "stdafx.h"

void encode(char *input, char *output, int start); // шифрование
void decode(char *input, char *output, int start); // расшифровка

int main(int argc, char* argv[])
{
setlocale(LC_ALL, "rus"); // определить кодовую страницу для России
if (argc!=5) { // задано недостаточное количество параметров командной строки
cout << "Образец запуска: ";
cout << "cezar_ascii.exe encode/decode offset ";
cout << "input_file - имя входного файла ";
cout << "output_file - имя выходного файла ";
cout << "encode - зашифровать ";
cout << "decode - расшифровать ";
cout << "offset - величина смещения алфавита замены ";
exit(1);
}

for (unsigned int i=0; i
if (!isdigit(argv[4][i])) {
cout << "Величина смещения алфавита должна быть числом ";
exit(1);
}
}

if (toupper(*argv[3])=='E') { // 3-им параметром в командной строке задано Encode - зашифровываем
encode(argv[1], argv[2], atoi(argv[4]));
} else { // иначе расшифровываем
decode(argv[1], argv[2], atoi(argv[4]));
}

return 0;
}

// шифрование
void encode(char *input, // имя входного файла
char *output, // имя выходного файла
int start) { // величина смещения алфавита

ifstream in(input, ios::in | ios::binary);
ofstream out(output, ios::out | ios::binary);
try {
if (!in) {
cerr << "Не могу открыть входной файл. ";
exit(1);
}
if (!out) {
cerr << "Не могу открыть выходной файл. ";
in.close();
exit(1);
}

int ch; // для хранения считываемого символа
do {
ch = in.get(); // считываем из файла очередной символ
if (!in.eof()) { // признак конца файла не обрабатываем
ch += start; // производим сдвиг на заданную величину по таблице кодов ASCII
if (ch>255) {
ch -= 255; // сдвиг циклический
}
out.put((char) ch); // записать измененный символ в файл результата
}
} while (!in.eof());
} catch (char *errMess) { // если ошибка
cerr << errMess << endl;
if (in) {
in.close();
}
if (out) {
out.close();
}
}
// закрыть используемые файлы
if (in) {
in.close();
}
if (out) {
out.close();
}
}

// расшифровка
void decode(char *input, char *output, int start) {

ifstream in(input, ios::in | ios::binary);
ofstream out(output, ios::out | ios::binary);
try {
if (!in) {
cerr << "Не могу открыть входной файл. ";
exit(1);
}
if (!out) {
cerr << "Не могу открыть выходной файл. ";
in.close();
exit(1);
}

int ch; // для хранения считываемого символа
do {
ch = in.get();
if (!in.eof()) { // признак конца файла не обрабатываем
ch -= start; // производим циклический сдвиг на заданную величину в обратном направлении
if (ch<0) {
ch += 255;
}
out.put((char) ch);
}
} while (!in.eof());
} catch (char *errMess) {
cerr << errMess << endl; // вывести сообщение об ошибке
if (in) {
in.close();
}
if (out) {
out.close();
}
}

// закрыть рание открытые файлы
if (in) {
in.close();
}
if (out) {
out.close();
}
}

this is in java


1.1. Шифр Цезаря

Шифр Цезаря основан на фиксированном смещении по кругу букв алфавита. Буквы сдвигаются по кругу, так что после последней буквы алфавита идет его первая буква. В следующем листинге (на языке java) приводится алгоритм шифрования на основе шифра Цезаря.

Листинг 1. класс CaesarCipher

package ru.festu.u031.asanov.security.ref1;

public class CaesarCipher {

/** Зашифровать строку */

public static String encrypt(String s, int key) {

String result = "";

for(int i = 0; i < s.length(); i++) {

// зашифровать каждый символ в строке

result += encrypt(s.charAt(i), key);

}

return result;

}

/** Зашифровать отдельный символ */

public static char encrypt(char c, int key) {

// преобразовать строчные буквы в прописные

if(c >= 'а' && c <= 'я') c = Character.toUpperCase(c);

// "повертуть" букву

if(c >= 'А' && c <= 'Я') c = rotate(c, key);

return c;

}

/** Расшифровать строку */

public static String decrypt(String s, int key) {

// выполнить шифрование с "обратным" ключем

return encrypt(s, -key);

}

/** Расшифровать отдельный символ */

public static char decrypt(char c, int key) {

if(c < 'А' || c > 'Я') return c;

else return rotate(c, key);

}

/** "Поворот" символа */

private static char rotate(char c, int key) {

int l = 'Я' - 'А';

c += key % l;

if(c < 'А') c += l;

if(c > 'Я') c -= l;

return c;

}

}

and this is my first try to make it in c but i failed to make it run cause couldnt realy understand what was his problem so i made the one i presented you but still couldnt solve the bug problem...this also has an error i couldnt find thank for your time



#include <stdio.h>
#include <string.h>

void menu ( void ) {
printf("Please enter a number: \n"
"1-Encrypt\n"
"2-Decrypt\n"
"3-Exit\n"
"prompt > ");
fflush( stdout );
}

int getchoice ( void ) {
char buff[BUFSIZ];
int choice = 0;
do {
menu();
if ( fgets( buff, sizeof buff, stdin ) != NULL ) {
/* success reading a line, does it make sense? */
if ( sscanf( buff, "%d", &choice ) != 1 ) {
printf( "Enter a number\n" );
}
} else {
/* user EOF, just exit now */
choice = 3;
}
} while ( choice < 1 || choice > 3 );
return choice;
}

void encode ( void )
{
char buff[BUFSIZ];
int i = 0;
int shift_value;
printf( "Doing encrypt\n" );
printf("\nPlease enter the text you wish to encrypt: ");
fgets(buff, sizeof(buff), stdin);
if ("%s" > 'Z')
{
"%s" -= 'Z' - 'A';
}
printf("\nEnter your encryption shift value (anything from +-1 to 25): ");
scanf ("%i", &shift_value);



{
while ( buff[i] != '\0' )
{
buff[i] = buff[i] + shift_value;
i++;

}
}
printf("\n Your encrypted text is: %s \n", buff);
}
void decode ( void )
{
char buff[BUFSIZ];
int i = 0;
int shift_value;
printf( "Doing decrypt\n" );
printf("\nPlease enter the text you wish to decrypt: ");
fgets(buff, sizeof(buff), stdin);
printf("\nEnter your encryption shift value (anything from +-1 to 25): ");
scanf ("%i", &shift_value);

{
while ( buff[i] != '\0' )
{
buff[i] = buff[i] - shift_value;
i++;
}
}
printf("\nYour decrypted text is: %s \n", buff);
}
int main ( ) {
int choice;
while ( (choice=getchoice()) != 3 ) {
if ( choice == 1 ) {

encode();
} else
if ( choice == 2 ) {
decode();
}
}


return 0;
}



i know that something doesnt seem right here but i still dont know how to change it and make it work this c language is realy a pain in the ***...



if ("%s" > 'Z')
{
"%s" -= 'Z' - 'A';
}

oesxyl
11-23-2008, 08:21 PM
no it is not homework it s just a try to understand c language ..mate i ve done this same code in 3 languages ...if you dont beleive i can show you down but in that i didnt have to owercome with that ascii problem whitch appears to me in c...and i have no idea how to turn this out ...
posting the code is not a poof but I must believe you, that's fair.

pascal and c, is mapping almost one to one, :)


if ("%s" > 'Z')
{
"%s" -= 'Z' - 'A';
}

this have no sense and also give error when compile you can remove it.

this is a link to the ascii table:
http://www.asciitable.com/

as you can see not all values are printable. I get the code you posted and I must test it, then I come back with feedback.

best regards

oesxyl
11-23-2008, 08:36 PM
you have a problem, your algorithm is wrong:

http://ru.wikipedia.org/wiki/%D0%A8%D0%B8%D1%84%D1%80_%D0%A6%D0%B5%D0%B7%D0%B0%D1%80%D1%8F

do you need text to use upper and lower case characters or only one type?. In this last case which one?

regards

BISKOT188
11-23-2008, 08:41 PM
well i didnt tell you to believe me i just trying to learn a couple of things
for the ascii yes i saw that page before cause i searched that well i know that not all of them are prinatable so i have to figure out a loop ..to make is run.. as far as i remember is is from 65 to 90 and 97 to 122 but i dont know how to make that loop inside this chars only ..

and about the code i gave you my first try it makes if you think it a bit different and see all the code anyway ....

there is an error c2016 if i remember well but i tried to do like this

instead of that 2 lines

[code]

int x;
if (x > 'Z')
x -= 'Z' - 'A';

printf("\n Your encrypted text is: %x \n", buff);
[\code]

well in that way i could make it run normanly but there still was a problem
the result of the encryption was always the same no metter what was the original text you put in so it still gave no normal result but the decryption work 100% so that made me angry a bit cause i could nt figure the way to make it work also right well have a look maybe you ll come up with something thanks again for your time!!best regards!

BISKOT188
11-23-2008, 08:55 PM
well based on the cesar cryptografy it is only for caps lock...chars!

oesxyl
11-23-2008, 08:55 PM
well i didnt tell you to believe me i just trying to learn a couple of things
for the ascii yes i saw that page before cause i searched that well i know that not all of them are prinatable so i have to figure out a loop ..to make is run.. as far as i remember is is from 65 to 90 and 97 to 122 but i dont know how to make that loop inside this chars only ..

and about the code i gave you my first try it makes if you think it a bit different and see all the code anyway ....

there is an error c2016 if i remember well but i tried to do like this
this error don't tell me anything because is compiler specific. I use gcc.



instead of that 2 lines

[code]

int x;
if (x > 'Z')
x -= 'Z' - 'A';

printf("\n Your encrypted text is: %x \n", buff);
[\code]

this code will change only once the value of x and buff is a array of chars, don't work.


well in that way i could make it run normanly but there still was a problem
the result of the encryption was always the same no metter what was the original text you put in so it still gave no normal result but the decryption work 100% so that made me angry a bit cause i could nt figure the way to make it work also right well have a look maybe you ll come up with something thanks again for your time!!best regards!

best regards

BISKOT188
11-23-2008, 09:04 PM
this error don't tell me anything because is compiler specific. I use gcc.


this code will change only once the value of x and buff is a array of chars, don't work.



best regards

thats the reason it always show me the same result ...
it said that the left value should be equal to the right one ..

oesxyl
11-23-2008, 09:06 PM
well based on the cesar cryptografy it is only for caps lock...chars!


#include <stdio.h>
#include <string.h>

void menu(void){
printf("Please enter a number: \n"
"1-Encrypt\n"
"2-Decrypt\n"
"3-Exit\n"
"prompt > ");
fflush( stdout );
}

int getchoice(void){
char buff[BUFSIZ];
int choice = 0;
do {
menu();
if(fgets( buff, sizeof buff, stdin ) != NULL){
/* success reading a line, does it make sense? */
if(sscanf( buff, "%d", &choice) != 1){
printf("Enter a number\n");
}
}else{
/* user EOF, just exit now */
choice = 3;
}
}while(choice < 1 || choice > 3);
return choice;
}

void encode(void){
char buff[BUFSIZ];
int i = 0;
int shift_value;
printf( "Doing encrypt\n" );
printf("\nPlease enter the text you wish to encrypt: ");
fgets(buff, sizeof(buff), stdin);
printf("\nEnter your encryption shift value (anything from +-1 to 25): ");
scanf("%i", &shift_value);
while(buff[i] != '\0'){
if(buff[i] >= 'A' && buff[i] <= 'Z'){
buff[i] = 'A' + (buff[i] - 'A' + shift_value) % 26;
}
i++;
}
printf("\n Your encrypted text is: %s \n", buff);
}

void decode(void){
char buff[BUFSIZ];
int i = 0;
int shift_value;
printf( "Doing decrypt\n" );
printf("\nPlease enter the text you wish to decrypt: ");
fgets(buff, sizeof(buff), stdin);
printf("\nEnter your encryption shift value (anything from +-1 to 25): ");
scanf ("%i", &shift_value);

while(buff[i] != '\0'){
if(buff[i] >= 'A' && buff[i] <= 'Z'){
buff[i] = 'A' + (buff[i] - 'A' - shift_value) % 26;
}
i++;
}
printf("\nYour decrypted text is: %s \n", buff);
}

int main(){
int choice;
while((choice=getchoice()) != 3 ){
if(choice == 1){
encode();
}else{
if(choice == 2){
decode();
}
}
}
return 0;
}


this will not encode/decode, will remain unchanged, any char which is not between 'A' and 'Z'

best regards

BISKOT188
11-23-2008, 09:10 PM
error C2446: '>' : no conversion from 'int' to 'const char *'

error C2040: '>' : 'const char [3]' differs in levels of indirection from 'int'

error C2106: '-=' : left operand must be l-value

all this erros in that privius line i post the fist i could understand i think there is a need to do something like ..



gets_s(key,20);

for(int i=0; key[i] !='\0'; i++)
{
if(!isdigit(key[i]))
{
printf ("Your key is not number! Try again \n");
return;
}
}
int k = atoi(key);

BISKOT188
11-23-2008, 09:13 PM
damn:( i will go and hit my head to the wall past 3 days ..i cant figre a simple if ..thanks mate it was a big help..:(((

well it s realy funny ...sometimes the easiest way to solve a problem is to try the most simple thing ....

BISKOT188
11-23-2008, 09:19 PM
but still mate something is rong with the decryption now if you put in BOOK IT ENCRYPTS with key 20 to VIIE if you put to decrypt VIIE with key 20 it doesnt give BOOK lol

oesxyl
11-23-2008, 09:24 PM
error C2446: '>' : no conversion from 'int' to 'const char *'

error C2040: '>' : 'const char [3]' differs in levels of indirection from 'int'

error C2106: '-=' : left operand must be l-value

all this erros in that privius line i post the fist i could understand i think there is a need to do something like ..



gets_s(key,20);

for(int i=0; key[i] !='\0'; i++)
{
if(!isdigit(key[i]))
{
printf ("Your key is not number! Try again \n");
return;
}
}
int k = atoi(key);

you don't need that code. if you want to convert to upper case use this inside the while loop:



if(buff[i] >= 'a' && buff[i] <= 'z'){
buff[i] += 'A' - 'a';
}


best regards

oesxyl
11-23-2008, 09:28 PM
but still mate something is rong with the decryption now if you put in BOOK IT ENCRYPTS with key 20 to VIIE if you put to decrypt VIIE with key 20 it doesnt give BOOK lol
yes, give B551, probably I do something wrong somewhere. I will see what's wrong and come back.

best regards

BISKOT188
11-23-2008, 09:44 PM
I m working on it also there are must be a simple thing we didnt see it s obvious it gives the first letter correctly why the other three are nt decoding right..

oesxyl
11-23-2008, 09:55 PM
I m working on it also there are must be a simple thing we didnt see it s obvious it gives the first letter correctly why the other three are nt decoding right..
solved: it become less then 0 if we substract shift_value so we must add 26.


#include <stdio.h>
#include <string.h>

void menu(void){
printf("Please enter a number: \n"
"1-Encrypt\n"
"2-Decrypt\n"
"3-Exit\n"
"prompt > ");
fflush( stdout );
}

int getchoice(void){
char buff[BUFSIZ];
int choice = 0;
do {
menu();
if(fgets( buff, sizeof buff, stdin ) != NULL){
/* success reading a line, does it make sense? */
if(sscanf( buff, "%d", &choice) != 1){
printf("Enter a number\n");
}
}else{
/* user EOF, just exit now */
choice = 3;
}
}while(choice < 1 || choice > 3);
return choice;
}

void encode(void){
char buff[BUFSIZ];
int i = 0;
int shift_value;
printf( "Doing encrypt\n" );
printf("\nPlease enter the text you wish to encrypt: ");
fgets(buff, sizeof(buff), stdin);
printf("\nEnter your encryption shift value (anything from +-1 to 25): ");
scanf("%i", &shift_value);
while(buff[i] != '\0'){
if(buff[i] >= 'A' && buff[i] <= 'Z'){
buff[i] = 'A' + (buff[i] - 'A' + shift_value) % 26;
}
i++;
}
printf("\n Your encrypted text is: %s \n", buff);
}

void decode(void){
char buff[BUFSIZ];
int i = 0;
int shift_value;
printf( "Doing decrypt\n" );
printf("\nPlease enter the text you wish to decrypt: ");
fgets(buff, sizeof(buff), stdin);
printf("\nEnter your encryption shift value (anything from +-1 to 25): ");
scanf ("%i", &shift_value);

while(buff[i] != '\0'){
if(buff[i] >= 'A' && buff[i] <= 'Z'){
int c = buff[i] - 'A' - shift_value;
if(c < 0)
c += 26;
buff[i] = 'A' + c % 26;
}
i++;
}
printf("\nYour decrypted text is: %s \n", buff);
}

int main(){
int choice;
while((choice=getchoice()) != 3 ){
if(choice == 1){
encode();
}else{
if(choice == 2){
decode();
}
}
}
return 0;
}

test it with different value from 'A' - 'Z' and 1 - 25 for shift, mainly to the lower and upper limits of the ranges.

best regards

BISKOT188
11-23-2008, 10:25 PM
great job mate thanks a lot seems it was a guite nice project well :) just for the record but i dont know if i should post this codes here this might be a homework for someone i also developed another code for cryptograffy :) encoding and decoding:))
i ll post them have a look:)) i wont tell the name it is not that easy to understand whitch it is:))




#include<stdio.h>
#include<string.h>
void main()
{
int ch,a1,b1,a,b,c,d,d1[15],h,n,i=0;
char str1[80],ek[80];
printf("Dwse to keimeno\n");
gets(str1);
do
{
printf("give key \na:");
scanf("%d",&a);
printf("\nb:");
scanf("%d",&b);
a1=a;
b1=b;
b=26;
d=1;
while(d!=0)
{


c=a/b;

d=a%b;
d1[i]=d;
a=b;
b=d;
i=i++;



}

n=i-1;





if(d1[n-1]==1)
{
printf("\nthe numbers are first \n\n");
ch=1;

}
else
{
printf("\n not first \n\n");
ch=0;
}
}
while(ch==0);
a=a1;
b=b1;
printf("\key is(%d,%d):\n",a,b);

printf("\nthe text %s lenght %d \n",str1,strlen(str1));
n=strlen(str1);

ek[n]='\0';
h=strlen(ek);
for (i=0; i<h; i++)
{
str1[i]=str1[i]-97;
ek[i]=((a*str1[i]+b)%26)+97;
printf("%c -> %d to \n",str1[i]+97,str1[i]);
}

printf("\n\n encrypted text i:%s \n",ek);
for (i=0; i<h; i++)
{
printf("%c -> %d \n",ek[i],ek[i]-97);
}
printf("encrypted:%s \n\n",ek);

}



/*int n,i,h,a,b;
char str1[80],str2[80],ek[80];
printf("give text\n");
gets(str1);
printf("give key\na:");
scanf("%d",&a);
printf("\nb:");
scanf("%d",&b);
printf("\n key is (%d,%d):\n",a,b);
i=0;
printf(" text is %s lenght %d \n",str1,strlen(str1));

n=strlen(str1);

printf("mhkos %d \n",n);
ek[n]='\0';
h=strlen(ek);
for (i=0; i<h; i++)
{
str1[i]=str1[i]-97;
ek[i]=((a*str1[i]+b)%26)+97;

printf("to %c %d %dto \n",str1[i],str1[i],h);


}
for (i=0; i<h; i++)
{printf("to %c %d to \n",ek[i],ek[i]-97);}
printf("encryptedi:%s \n",ek);
*/

the code in the comments is the second way to make it work..:))

and the decryption code is ..



#include<stdio.h>
#include<string.h>
void mul(int a1,int b1,int *d,int *x,int *y);
void main()
{
int ch,xx,a1,b1,a,b,c,d,d1[15],h,n,x,key,y,i=0;
char str1[80],dk[80];
printf("give text\n");
gets(str1);
do
{
printf("give key\na:");
scanf("%d",&a);
printf("\nb:");
scanf("%d",&b);

a1=a;
b1=b;
b=26;
mul(a,b,&d,&x,&y);
key=x;
if (key<0)
{
key=26+key;
}
printf("\n1/a:%d \n",key);

d=1;
while(d!=0)
{


c=a/b;

d=a%b;
d1[i]=d;
a=b;
b=d;
i=i++;



}

n=i-1;





if(d1[n-1]==1)
{
printf("\n first\n\n");
ch=1;

}
else
{
printf("\nnot first\n\n");
ch=0;
}
}
while(ch==0);
a=a1;
b=b1;
printf("\nkey (%d,%d):\n",a,b);

printf("\ntext %s lenght %d \n",str1,strlen(str1));
n=strlen(str1);

dk[n]='\0';
h=strlen(dk);
for (i=0; i<h; i++)
{
str1[i]=str1[i]-97;
xx=(str1[i]-b)%26;
if (xx<0)
{
xx=26+xx;
}

dk[i]=((key*(xx))%26)+97;
printf("%c -> %d\n",str1[i]+97,str1[i]);
}
printf("\n\ndecrypted:%s \n",dk);
for (i=0; i<h; i++)
{
printf("%c -> %d\n",dk[i],dk[i]-97);
}
printf("decrypted:%s \n\n",dk);

}

void mul(int a1,int b1,int *d1,int *x1,int *y1)
{int c,d,x,y;
if(b1==0)
{
*d1=a1;
*x1=1;
*y1=0;


}
else{
d=*d1;
x=*x1;
y=*y1;



c=a1%b1;

mul(b1,c,&d,&x,&y);


*d1=d;
*x1=y;
*y1=x-(a1/b1)*(y);

}

}



this is another nice one they work 100% seperatly but i didnt try to make them a unique code with a menu it starts to be a big code and too complicated :))) for me to check:)))
the one works very good
thanks for your help:)) have a look at the codes you might see them interesting:))

oesxyl
11-23-2008, 11:01 PM
nice, I will look, :)

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum