Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   Программирование и базы данных (http://forum.oszone.net/forumdisplay.php?f=21)
-   -   Кодирка (http://forum.oszone.net/showthread.php?t=29770)

Guest 28-04-2004 09:07 205717

он у меня шифрует но не берет весь текст только частицу прога у меня на C++Builder  что делать ??? HELP

DYURIK 28-04-2004 15:20 205718

а можеш  привести код, и текст, который шифруеш?

Kod girl 28-04-2004 16:40 205719

Это *Тритемиус бтри ключа по выбору Linecrypt ,NolineCript ,TextCrypt на первом и втором *как ключ *набирается только цифры *а на третьем *символы ну вот у меня работает TextCrypt авот те двое полностью не шифрует

Код:

int checkRbutton()
{
 *if(Form1->rbutton1->Checked) return 1;
 *if(Form1->rbutton2->Checked) return -1;
 *}

void LineCrypt(int Encode)
{int counter=1;
char ch;
int sign;

char *pMemo1,*pMemo2/*,pKey1,pKey2,UrovResalt*/;


 int TextLen=Form1->Memo1->Text.Length();

 strmemo1.SetLength(TextLen) ;
 strmemo2.SetLength(TextLen) ;

 *strmemo1=Form1->Memo1->Text;

 *pMemo1=strmemo1.c_str();
 *pMemo2=strmemo2.c_str();

int *tempResult=0 ,pKey1=0,pKey2=0,UrovResalt=0;
 pKey1=StrToInt(Form1->Edit3->Text);
 pKey2=StrToInt(Form1->Edit4->Text);

 sign=Encode;

for(int k=1;k<=TextLen;k++)
{
 * * * *ch=pMemo1[k];
 * * * *UrovResalt=pKey1*k+pKey2;
 * * * *tempResult=(ch+sign*UrovResalt)%256;
 * * * *pMemo2[k]=(char)tempResult;
 * * * *//counter++;

}Form1->Memo2->Text=pMemo2;}

void NoLineCrypt(int Encode)
{int counter=1;
char ch;
int sign;

char *pMemo1,*pMemo2;


 int TextLen=Form1->Memo1->Text.Length();

 strmemo1.SetLength(TextLen) ;
 strmemo2.SetLength(TextLen) ;

 strmemo1=Form1->Memo1->Text;

 pMemo1=strmemo1.c_str();
 pMemo2=strmemo2.c_str();

int *tempResult=0 ,pKey1=0,pKey2=0,pKey3=0,UrovResalt=0;
 pKey1=StrToInt(Form1->Edit5->Text);
 pKey2=StrToInt(Form1->Edit6->Text);
 pKey3=StrToInt(Form1->Edit7->Text);

 sign=Encode;

for(int k=1;k<=TextLen;k++)
{
 * * * *ch=pMemo1[k];
 * * * *UrovResalt=pKey1*k*k+pKey2*k+pKey3;
 * * * *tempResult=(ch+sign*UrovResalt)%256;
 * * * *pMemo2[k]=(char)tempResult;
 * * * *//counter++;
}Form1->Memo2->Text=pMemo2;
}



void TextCrypt(int Encode)
{int counter=0;
char ch;
int sign;

char *pMemo1,*pMemo2,*pKey;


 int TextLen=Form1->Memo1->Text.Length();
 int length=Form1->k1->Text.Length();

 strmemo1.SetLength(TextLen) ;
 strmemo2.SetLength(TextLen) ;
 strkey.SetLength(length);

 strmemo1=Form1->Memo1->Text;
 strkey=Form1->k1->Text;


 pMemo1=strmemo1.c_str();
 pKey=strkey.c_str();
 pMemo2=strmemo2.c_str();

int tempResult=0;


 sign=Encode;

for(int k=0;k<TextLen;k++)
{
 * * * *ch=pMemo1[k];
 * * * *tempResult=(ch+sign*pKey[counter])%256;
 * * * *pMemo2[k]=(char)tempResult;
 * * * *counter++;
 * * * *counter%=length;
}Form1->Memo2->Text=pMemo2;}

//---------------------------------------------------------------------------

void __fastcall TForm1::de_codeClick(TObject *Sender)
{
if(!checkRbutton())
 * * * * return;

 * *switch (Form1->PageControl1->TabIndex)
 * *{
 * * * case 0: NoLineCrypt(checkRbutton());
 * * * * * * * break;
 * * * case 1: TextCrypt(checkRbutton());
 * * * * * * * break;
 * * * case 2: LineCrypt(checkRbutton());
 * * * * * * * break;
 * * * default : ;
 * *}

[s]Исправлено: Prisoner, 3:17 29-04-2004[/s]

DYURIK 30-04-2004 16:06 205720

При переборе символов текста существует вероятность напоротся на '\0'. Тестировал не этот счет?

Kod girl 30-04-2004 17:18 205721

Если честно, я тоже так думаю, но не знаю что делать? Можешь помочь?


[s]Исправлено: Prisoner, 3:34 1-05-2004[/s]


Время: 16:14.

Время: 16:14.
© OSzone.net 2001-