資源簡介

代碼片段和文件信息
/*************************************************************************/
/*???????????????????????????????????????????????????????????????????????
/*?Describe?:?ADFGVX?Cipher?Function
/*?Input?key?and?plaintext
/*?Transform?key?into?a?matrix?of?5*5???
/*?Author?:?ZongNanYaoFengyi????????????????????????????????????????????
/*?Date?:?2009?-?7?-?23?13:09????????????????????????????????????????????
/*???????????????????????????????????????????????????????????????????????
/*************************************************************************/
#include?“string.h“
#include?“ctype.h“
#include?“stdlib.h“
#include?“stack-c.h“
int?ADFGVX(char?*keychar?*ciphertext)
{
int?ijk;???????????//Define?cycle?control?variables
char?Location[6]?=?{‘A‘‘D‘‘F‘‘G‘‘V‘‘X‘};???//?Define?look-up?table?used?to?locate?coordinate
int?row;?????????//?Row?coordinates
int?grade;???????//Column?coordinates
int?plaintextLength;?
int?ciphertextLength;
???????char?*plaintext;
ciphertextLength?=?strlen(ciphertext);?//Compute?length
????plaintext?=?(char?*)malloc(ciphertextLength+1);?//??Encryption?for?every?letter
????strcpy(plaintextciphertext);
plaintextLength?=?strlen(plaintext);????????
for(i?=?0k?=?0;i? {
if(plaintext[i]?==?‘?‘)?
{
k?-=?2;
continue;???????//?Filter?Spaces
}
for(j?=?0;j?36;j?++)
if(key[j]?==?tolower(plaintext[i]))
break;??????????????????//?Search?the?letter?in?the?alphabet
row?=?j?/?6;
grade?=?j?%?6;????????????????????
ciphertext[k]?=?Location[row];
ciphertext[k?+?1]?=?Location[grade];
}
ciphertext[k]?=?‘\0‘;
free(plaintext);
return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1696??2009-08-20?11:22??ADFGVX.c
?????文件???????1689??2009-08-23?00:09??ADFGX.c
?????文件???????1139??2009-08-23?00:09??Affine.c
?????文件???????1539??2009-08-20?11:21??Beaufort.c
?????文件???????1516??2009-08-20?11:21??Box.c
?????文件???????1313??2009-08-22?11:22??Caesar.c
?????文件???????1249??2009-08-22?11:25??CharSingTabRe.c
?????文件???????1592??2009-08-20?11:19??DeADFGVX.c
?????文件???????1418??2009-08-23?00:23??DeADFGX.c
?????文件???????1242??2009-08-22?11:26??DeAffine.c
?????文件???????1381??2009-08-20?11:07??DeBeaufort.c
?????文件???????1564??2009-08-20?11:08??DeBox.c
?????文件???????1381??2009-08-22?11:26??DeCaesar.c
?????文件???????1049??2009-08-22?11:27??DeCharSingTabRe.c
?????文件???????1143??2009-08-22?11:28??DeGCaesar.c
?????文件???????1430??2009-08-20?11:20??DeMultiplicator.c
?????文件???????2756??2009-08-23?00:25??DePlayfair.c
?????文件???????1964??2009-08-22?11:33??DeSingTabRe.c
?????文件???????2803??2009-08-20?11:19??DeTranspose.c
?????文件???????1450??2009-08-23?00:04??DeVigenere.c
?????文件???????1141??2009-08-22?11:31??GCaesar.c
?????文件???????1280??2009-08-20?11:06??Multiplicator.c
?????文件???????3496??2009-08-23?00:10??Playfair.c
?????文件???????2071??2009-08-22?11:33??SingleTableRe.c
?????文件???????2329??2009-08-23?00:37??Transpose.c
?????文件???????1505??2009-08-20?11:03??Vigenere.c
-----------?---------??----------?-----??----
????????????????43136????????????????????26
評論
共有 條評論