Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3cde4be54 | ||
|
|
3a2e110ad2 | ||
|
|
c68c270dbf | ||
|
|
957d28ff06 | ||
|
|
52769a7985 | ||
|
|
0242ed0256 |
No files matched your search
+1
-139
@@ -1,139 +1 @@
|
|||||||
Ô XFNSY UWêYWJ ! LWFSIJ âRJ ! TM ! OJ YTRGJ à LJSTZC !
|
02 03 20 24 00 31 33 00 33 01 13 33 03 24 11 01 23 01 30 14 01 00 30 23 04 01 13 01 24 30 34 42 01 34 24 01 20 22 03 40 03 20 00 01 24 10 30 33 11 01 22 30 24 13 02 30 34 33 02 31 03 33 23 20 24 30 34 02 20 22 24 01 24 03 31 03 02 10 30 23 31 00 22 01 24 30 23 04 33 01 20 22 00 03 20 00 10 01 00 13 01 30 22 01 04 30 24 14 01 34 33 12 22 01 34 33 20 00 20 22 03 10 30 24 02 20 11 33 22 03 10 33 30 20 42 11 01 02 34 02 10 14 33 20 02 00 00 30 34 00 01 33 03 43 30 24 24 03 24 00 01 11 03 24 02 22 30 23 04 33 01 20 22 03 11 20 00 10 01 02 00 22 01 11 20 01 34 11 01 31 33 30 13 33 02 01 00 11 03 23 30 34 33 02 34 02 32 34 20 40 30 20 00 00 30 24 12 33 30 24 00 10 33 30 20 00 40 30 20 33 22 01 12 33 30 24 00 11 34 30 34 33 10 14 33 20 02 00 02 30 34 33 20 00 32 34 20 22 01 33 01 31 30 34 02 02 01 31 34 20 02 32 34 20 22 01 02 00 23 30 33 00 31 30 34 33 24 30 34 02 01 40 01 34 42 23 30 34 33 20 33 31 30 34 33 22 34 20 11 03 24 02 02 30 24 00 30 23 04 01 03 34 11 30 24 00 03 20 22 03 31 20 01 33 33 01 31 30 34 33 03 31 31 34 20 20 22 23 03 31 31 01 22 22 01 11 34 24 01 40 30 20 42 11 30 34 10 01 02 03 11 30 10 00 33 20 24 01 01 02 00 22 01 10 20 01 22 01 24 00 33 30 34 40 01 33 00 31 03 33 22 03 23 03 20 24 10 30 23 23 01 34 24 31 33 01 22 01 24 12 03 24 00 20 22 00 20 01 24 00 22 01 13 01 24 33 01 14 34 23 03 20 24 31 03 33 22 34 20 24 30 34 02 40 20 40 30 24 02 01 00 24 30 34 02 02 30 23 23 01 02 03 34 10 14 01 40 01 00 11 01 02 13 01 22 20 01 33 02 11 30 33 23 03 24 00 11 03 24 02 22 01 34 33 02 23 03 20 02 30 24 02 20 22 11 33 30 04 01 22 01 02 10 22 01 12 02 11 01 00 30 34 00 01 02 22 01 02 31 33 20 02 30 24 02 01 00 23 01 00 01 24 22 20 04 01 33 00 22 01 02 14 30 23 23 01 02 30 33 20 22 01 02 00 22 30 20 24 11 01 24 30 34 02 34 24 01 03 34 00 33 01 14 34 23 03 24 20 00 32 34 20 24 01 22 01 10 30 24 24 03 00 31 30 20 24 00 01 00 11 03 24 02 22 20 24 20 32 34 20 00 33 03 23 31 01 01 24 10 14 03 24 01 01 00 02 30 34 12 12 33 01 01 00 00 30 23 04 01 20 22 02 12 30 24 00 31 30 34 33 00 33 30 34 40 01 33 11 20 01 34 11 01 00 24 04 33 01 34 42 01 12 12 30 33 00 02 20 22 02 02 03 13 20 00 01 24 00 01 24 40 03 20 24 20 22 02 02 30 24 00 10 30 23 23 01 11 01 02 23 30 33 00 02 32 34 20 00 00 01 24 00 22 01 23 34 33 11 01 22 01 34 33 00 30 23 04 01 02 03 24 02 22 30 20 02 03 24 02 04 34 00 02 03 24 02 13 34 20 11 01 20 22 02 01 33 33 01 24 00 20 10 20 04 03 02 20 22 02 02 30 24 00 23 10 14 03 24 00 02 00 03 24 00 20 13 24 30 33 03 24 00 02 20 22 02 24 30 24 00 31 03 02 22 01 34 33 31 03 33 00 11 01 22 03 13 33 03 24 11 01 10 30 24 32 34 00 01 20 33 03 20 31 30 34 33 22 01 02 02 03 34 40 01 33 01 32 34 20 00 00 01 22 01 02 03 20 24 00 22 20 01 34 23 01 02 12 33 33 01 02 01 40 20 01 24 02 40 30 34 02 03 31 31 30 33 00 01 33 23 30 24 11 20 01 34 01 40 20 01 24 02 40 30 34 02 03 31 31 30 33 00 01 33 23 03 00 00 01 31 33 00 33 01 20 22 02 01 02 00 02 30 34 40 01 24 34 10 03 22 23 01 01 24 24 30 02 30 34 33 02 00 33 30 34 04 22 02 11 01 22 03 31 03 33 30 22 01 11 20 00 01 03 34 42 03 31 00 33 01 02 03 22 22 01 44 04 33 03 40 01 44 22 01 02 04 10 14 01 33 02 01 00 22 01 02 10 22 03 20 01 02 01 00 11 01 22 03 11 20 01 34 11 34 10 14 33 20 02 00 03 34 02 34 31 33 23 01 23 30 23 01 24 00 40 20 40 03 24 00 03 20 23 01 44 40 30 34 02 03 20 23 01 44 01 24 40 30 34 02 03 20 23 03 24 00 12 33 33 01 02 40 30 34 02 12 01 33 23 01 33 01 44 23 01 02 31 22 03 20 01 02 20 22 02 01 02 00 11 20 00 32 34 20 22 01 02 00 04 30 24 11 10 22 03 20 33 01 33 11 03 24 02 22 01 34 33 24 34 20 00 10 01 02 31 01 34 31 22 01 02 13 03 33 02 22 30 20 24 11 34 31 33 30 13 33 02 32 34 20 22 34 20 00 11 30 24 00 22 23 01 01 02 00 10 30 34 40 01 33 00 01 11 01 40 30 20 22 01 02 31 34 20 02 20 22 02 01 24 01 02 00 03 22 22 11 03 24 02 22 01 02 40 01 24 00 02 11 03 24 02 22 01 02 12 22 30 00 02 40 01 33 02 22 01 02 24 30 20 33 02 10 14 01 40 03 22 01 00 02 01 00 22 01 02 02 03 24 13 22 03 24 00 02 04 20 22 22 30 00 02 22 01 02 43 01 34 42 12 20 42 02 02 34 33 22 01 02 00 30 20 22 01 02 20 20 10 01 34 42 40 01 33 02 32 34 20 10 01 00 03 31 00 33 01 03 22 22 03 20 00 22 30 24 00 13 30 33 13 20 20 20 30 14 00 03 24 11 20 02 32 34 01 22 04 03 02 14 22 03 02 10 14 01 44 10 01 02 04 03 33 04 03 33 01 02 02 00 03 22 01 22 10 14 03 12 03 34 11 11 01 00 01 02 23 01 23 04 33 01 02 10 14 03 33 13 32 34 01 22 01 04 30 34 33 33 01 03 34 33 03 24 13 01 03 24 00 02 01 02 13 22 03 20 40 01 02 01 00 02 01 02 04 03 33 33 01 02 12 33 30 00 00 01 03 34 13 20 04 01 00 02 30 24 30 24 13 22 01 30 00 30 24 02 03 24 13 02 01 02 00 12 20 13 10 20 01 22 00 03 24 11 20 02 32 34 01 22 01 02 10 14 20 01 24 02 11 03 24 02 10 01 02 03 24 13 40 20 01 24 24 01 24 00 04 30 20 33 01 01 00 32 34 01 22 03 23 30 34 10 14 01 14 30 33 33 20 04 22 01 01 02 02 03 20 23 03 34 40 30 22 30 43 01 34 42 10 30 23 23 01 11 03 24 02 34 24 01 33 34 10 14 01 01 24 00 33 01 01 24 00 03 04 30 34 10 14 01 24 30 20 33 01 01 00 04 30 34 33 11 30 24 24 01 03 34 02 30 22 01 20 22 11 03 24 02 22 01 02 00 33 30 34 02 11 01 0Line truncated
|
||||||
OJZSJ, NQ FAFNY JSHTW IJ QTSLX OTZWX UFWRN STZX,
|
|
||||||
NQ S'JS F UFX HTRUYé QJ STRGWJ ;
|
|
||||||
NQ éYFNY à HJY âLJ Tù QJ GTSMJZW KQJZWNY ;
|
|
||||||
NQ F HTSXNIéWé QF HWTNC IJ OéXZX-HMWNXY
|
|
||||||
YTZYJ WFDTSSFSYJ IFSX Q'TRGWJ.
|
|
||||||
|
|
||||||
NQ F INY : — « H'JXY QJ INJZ IJ UWTLWèX JY I'FRTZW.
|
|
||||||
OéXZX, VZN ATNY YTS KWTSY HWTNY ATNW QJ KWTSY IZ OTZW.
|
|
||||||
HMWNXY XTZWNY à VZN QJ WJUTZXXJ.
|
|
||||||
UZNXVZ'NQ JXY RTWY UTZW STZX, OJ AJZC RTZWNW UTZW QZN ;
|
|
||||||
IFSX XTS YTRGJFZ, ITSY O'FN QF UNJWWJ UTZW FUUZN,
|
|
||||||
NQ R'FUUJQQJ I'ZSJ ATNC ITZHJ.
|
|
||||||
|
|
||||||
« XF ITHYWNSJ JXY QJ HNJQ JSYW'TZAJWY ; UFW QF RFNS,
|
|
||||||
HTRRJ ZS UèWJ Q'JSKFSY, NQ YNJSY QJ LJSWJ MZRFNS ;
|
|
||||||
UFW QZN STZX ANATSX JY STZX XTRRJX ;
|
|
||||||
FZ HMJAJY IJX LJôQNJWX ITWRFSY IFSX QJZWX RFNXTSX,
|
|
||||||
NQ IéWTGJ QJX HQJKX IJ YTZYJX QJX UWNXTSX
|
|
||||||
JY RJY JS QNGJWYé QJX MTRRJX.
|
|
||||||
|
|
||||||
« TW NQ JXY, QTNS IJ STZX, ZSJ FZYWJ MZRFSNYé
|
|
||||||
VZN SJ QJ HTSSFîY UTNSY, JY IFSX Q'NSNVZNYé
|
|
||||||
WFRUJ JSHMFîSéJ, JY XTZKKWJ JY YTRGJ ;
|
|
||||||
NQX KTSY UTZW YWTZAJW INJZ IJ YéSéGWJZC JKKTWYX ;
|
|
||||||
NQX X'FLNYJSY JS AFNS ; NQX XTSY HTRRJ IJX RTWYX
|
|
||||||
VZN YâYJSY QJ RZW IJ QJZW YTRGJ.
|
|
||||||
|
|
||||||
« XFSX QTN, XFSX GZY, XFSX LZNIJ, NQX JWWJSY NHN-GFX.
|
|
||||||
NQX XTSY RéHMFSYX, éYFSY NLSTWFSYX ; NQX S'TSY UFX
|
|
||||||
QJZW UFWY IJ QF LWFSIJ HTSVZêYJ.
|
|
||||||
O'NWFN. UTZW QJX XFZAJW OJ VZNYYJ QJ XFNSY QNJZ.
|
|
||||||
Ô RJX KWèWJX, OJ ANJSX ATZX FUUTWYJW RTS INJZ,
|
|
||||||
OJ ANJSX ATZX FUUTWYJW RF YêYJ ! » —
|
|
||||||
|
|
||||||
UWêYWJ, NQ X'JXY XTZAJSZ, HFQRJ JS STX OTZWX YWTZGQéX,
|
|
||||||
IJ QF UFWTQJ INYJ FZC FUôYWJX : — FQQJE,
|
|
||||||
GWFAJE QJX GûHMJWX JY QJX HQFNJX ! —
|
|
||||||
JY IJ Q'FINJZ IZ HMWNXY FZ XZUWêRJ RTRJSY :
|
|
||||||
— Ô ANAFSY, FNRJE-ATZX ! FNRJE. JS ATZX FNRFSY,
|
|
||||||
KWèWJX, ATZX KJWRJWJE RJX UQFNJX. —
|
|
||||||
|
|
||||||
NQ X'JXY INY VZ'NQ JXY GTS I'éHQFNWJW IFSX QJZW SZNY
|
|
||||||
HJX UJZUQJX éLFWéX QTNS IZ UWTLWèX VZN QZNY,
|
|
||||||
ITSY Q'âRJ JXY HTZAJWYJ IJ ATNQJX ;
|
|
||||||
UZNX NQ X'JS JXY FQQé, IFSX QJX AJSYX, IFSX QJX KQTYX,
|
|
||||||
AJWX QJX STNWX HMJAFQJYX JY QJX XFSLQFSYX GNQQTYX,
|
|
||||||
QJX DJZC KNCéX XZW QJX éYTNQJX.
|
|
||||||
|
|
||||||
NN.
|
|
||||||
|
|
||||||
HJZC AJWX VZN HJY FUôYWJ FQQFNY, Q'TSY éLTWLé.
|
|
||||||
|
|
||||||
NNN.
|
|
||||||
|
|
||||||
TM ! YFSINX VZJ Qà-GFX, MéQFX ! HMJE HJX GFWGFWJX,
|
|
||||||
X'éYFQJ Q'éHMFKFZI IJ YJX RJRGWJX HMFWLé,
|
|
||||||
VZJ QJ GTZWWJFZ, WFSLJFSY XJX LQFNAJX JY XJX GFWWJX,
|
|
||||||
KWTYYJ FZ LNGJY XTS TSLQJ Tù YTS XFSL X'JXY KNLé ;
|
|
||||||
|
|
||||||
HNJQ ! YFSINX VZJ QJX HMNJSX IFSX HJ XFSL ANJSSJSY GTNWJ,
|
|
||||||
JY VZJ QF RTZHMJ MTWWNGQJ, JXXFNR FZ ATQ OTDJZC,
|
|
||||||
HTRRJ IFSX ZSJ WZHMJ JSYWJ JS YF GTZHMJ STNWJ
|
|
||||||
JY GTZWITSSJ FZ XTQJNQ IFSX QJX YWTZX IJ YJX DJZC ;
|
|
||||||
|
|
||||||
YFSINX VZ'éHMJAJQéJ, JY XFSX ATNC, XFSX UFZUNèWJX,
|
|
||||||
YF YêYJ GQêRJ JXY Qà XZW ZS NSKâRJ UNJZ,
|
|
||||||
QNAWéJ FZC ANQX FKKWTSYX, RJZWYWNJ à HTZUX IJ UNJWWJX,
|
|
||||||
NHN, IJWWNèWJ YTN, RFWYDW, TS AJSI YTS INJZ !
|
|
||||||
|
|
||||||
HJ INJZ VZN S'JXY VZ'à YTN, RFWYDW, TS YJ QJ ATQJ !
|
|
||||||
TS QJ QNAWJ à RFSIWNS, HJ INJZ UTZW VZN YZ RJZWX !
|
|
||||||
IJX MTRRJX, HTRRJ YTN WJAêYZX IJ Q'éYTQJ,
|
|
||||||
UTZW êYWJ HFWINSFZC, UTZW êYWJ XéSFYJZWX,
|
|
||||||
|
|
||||||
IJX UWêYWJX, UTZW FATNW IJX UFQFNX, IJX HFWWTXXJX,
|
|
||||||
JY IJX OFWINSX Q'éYé WNFSY XTZX QJ HNJQ GQJZ,
|
|
||||||
UTZW FWLJSYJW QJZW RNYWJ JY UTZW ITWJW QJZWX HWTXXJX,
|
|
||||||
UTZW GTNWJ IJ GTS ANS, FXXNX UWèX I'ZS GTS KJZ,
|
|
||||||
|
|
||||||
FZ KTWGFS ITSY QF RFNS IFSX QJ RJZWYWJ JXY YWJRUéJ,
|
|
||||||
FZ QFWWTS HMFWLé I'TW VZN UFDJ JY VZN XTZWNY,
|
|
||||||
LWFSI INJZ ! WJYTZWSJ-YTN AJWX STZX, YêYJ HTZUéJ !
|
|
||||||
NQX AJSIJSY OéXZX-HMWNXY ! NQX AJSIJSY OéXZX-HMWNXY !
|
|
||||||
|
|
||||||
NQX QNAWJSY FZ GFSINY, UTZW VZJQVZJX XFHX XTWINIJX,
|
|
||||||
Q'éAFSLNQJ, QF QTN, Q'FZYJQ éUTZAFSYé,
|
|
||||||
JY QF OZXYNHJ FZC DJZC XéAèWJX JY HFSINIJX,
|
|
||||||
JY Q'éYTNQJ IZ HTJZW MZRFNS, QF AéWNYé !
|
|
||||||
|
|
||||||
QJX GTSX OJYéX, ANAFSYX, FZ GFLSJ, TZ RTWYX, FZC KQJZAJX,
|
|
||||||
Q'MTRRJ OZXYJ UWTXHWNY UFW HFWYTZHMJ XDQQF,
|
|
||||||
Q'NSSTHJSY éLTWLé, QJ IJZNQ XFHWé IJX AJZAJX,
|
|
||||||
QJX UQJZWX IJ Q'TWUMJQNS, NQX AJSIJSY YTZY HJQF !
|
|
||||||
|
|
||||||
YTZY ! QF KTN, QJ XJWRJSY VZJ INJZ YNJSY XTZX XF LFWIJ,
|
|
||||||
QJ XFNSY YJRUQJ Tù, RTZWFSY, YZ INX :NSYWTïGT,
|
|
||||||
NQX QNAWJSY YTZY ! UZIJZW, AJWYZ ! — RFWYDW, WJLFWIJ,
|
|
||||||
WTZAWJ YJX DJZC VZ'JRUQNY QF QZJZW IZ YTRGJFZ ; —
|
|
||||||
|
|
||||||
NQX AJSIJSY Q'FWHMJ FZLZXYJ Tù Q'MTXYNJ éYNSHJQQJ !
|
|
||||||
NQX AJSIJSY HMWNXY, YJ INX-OJ ! JY XJX RJRGWJX QNéX !
|
|
||||||
NQX AJSIJSY QF XZJZW VZN XZW XTS KWTSY WZNXXJQQJ,
|
|
||||||
JY QJX HQTZX IJ XJX RFNSX, JY QJX HQTZX IJ XJX UNJIX !
|
|
||||||
|
|
||||||
NQX AJSIJSY FZ GWNLFSI VZN HMJE QZN QJX FYYNWJ
|
|
||||||
QJ LWFSI HWZHNKNé XZW QJX MTRRJX UJSHMé ;
|
|
||||||
NQX AJSIJSY XF UFWTQJ, NQX AJSIJSY XTS RFWYDWJ,
|
|
||||||
JY YTS RFWYDWJ à YTN UFW-IJXXZX QJ RFWHMé !
|
|
||||||
|
|
||||||
YFSY UTZW QJX HTZUX IJ KTZJY VZ'NQ WJçZY à QF UTWYJ !
|
|
||||||
HéXFW ! YFSY UTZW Q'FRJS, YFSY UTZW Q'FQQéQZNF !
|
|
||||||
YFSY UTZW QF UNJWWJ Tù ANSY MJZWYJW XF YêYJ RTWYJ !
|
|
||||||
YFSY UTZW QJ IWFU WTZLN VZJ XF GFWGJ JXXZDF !
|
|
||||||
|
|
||||||
NQX AJSIJSY XJX LJSTZC RJZWYWNX, XF UFQRJ AJWYJ,
|
|
||||||
XF UQFNJ FZ KQFSH, XTS TJNQ YTZY GFNLSé I'NSKNSN,
|
|
||||||
XJX UQJZWX, XTS FLTSNJ, JY XF GTZHMJ JSYWTZAJWYJ,
|
|
||||||
JY QJ HWN VZ'NQ UTZXXF : QFRRF XFGFHYMFSN !
|
|
||||||
|
|
||||||
NQX AJSIJSY QJ XéUZQHWJ ! NQX AJSIJSY QJX YéSèGWJX !
|
|
||||||
QJX XéWFUMNSX HMFSYFSY FZ XJZNQ UWTKTSI IJX HNJZC,
|
|
||||||
JY QF RèWJ IJGTZY XTZX Q'FWGWJ FZC GWFX KZSèGWJX,
|
|
||||||
VZN, XJSYFSY Qà XTS KNQX, SJ QJAFNY UFX QJX DJZC !
|
|
||||||
|
|
||||||
TZN, HJX éAêVZJX, TZN, HJX RFWHMFSIX, TZN, HJX UWêYWJX
|
|
||||||
F Q'MNXYWNTS IZ HWNRJ, FXXTZAN, HTZWTSSé,
|
|
||||||
F HJ SéWTS WJUZ VZN WNY UFWRN QJX YWFîYWJX,
|
|
||||||
ZS UNJI XZW YMWFXéFX, ZS HTZIJ XZW UMWDSé,
|
|
||||||
|
|
||||||
FZ ATQJZW VZN YZF QJX QTNX à HTZUX IJ HWTXXJ,
|
|
||||||
FZ UNWFYJ JRUJWJZW SFUTQéTS IJWSNJW,
|
|
||||||
NAWJ IJZC KTNX, NRRTSIJ JSHTW UQZX VZJ KéWTHJ,
|
|
||||||
UTZWHJFZ IFSX QJ HQTFVZJ JY QTZU IFSX QJ HMFWSNJW,
|
|
||||||
|
|
||||||
NQX AJSIJSY, ô RFWYDW, QJ INJZ UJSXNK JY UâQJ
|
|
||||||
VZN, IJGTZY XZW QF YJWWJ JY XTZX QJ KNWRFRJSY,
|
|
||||||
YWNXYJ JY STZX XTZWNFSY IFSX STYWJ SZNY KFYFQJ,
|
|
||||||
XZW QJ STNW LTQLTYMF XFNLSJ éYJWSJQQJRJSY !
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
Let me not to the marriage of true minds
|
||||||
|
Admit impediments. Love is not love
|
||||||
|
Which alters when it alteration finds,
|
||||||
|
Or bends with the remover to remove:
|
||||||
|
O no! it is an ever-fixed mark
|
||||||
|
That looks on tempests and is never shaken;
|
||||||
|
It is the star to every wandering bark,
|
||||||
|
Whose worth’s unknown, although his height be taken.
|
||||||
|
Love’s not Time’s fool, though rosy lips and cheeks
|
||||||
|
Within his bending sickle’s compass come:
|
||||||
|
Love alters not with his brief hours and weeks,
|
||||||
|
But bears it out even to the edge of doom.
|
||||||
|
If this be error and upon me proved,
|
||||||
|
I never writ, nor no man ever loved.
|
||||||
|
|
||||||
|
William Shakespeare
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
gcc -Wall src/main.c src/functions.c src/caesar.c src/vigenere.c -o output/main && ./output/main $1 $2 $3 $4
|
gcc -Wall src/main.c src/functions.c src/caesar.c src/vigenere.c src/polybius.c -o main && ./main $1 $2 $3 $4
|
||||||
@@ -1,31 +1,6 @@
|
|||||||
#include "caesar.h"
|
#include "caesar.h"
|
||||||
|
|
||||||
#define BUFFER_SIZE 128
|
|
||||||
|
|
||||||
/*
|
|
||||||
This function read the file block by block until the end of it
|
|
||||||
*/
|
|
||||||
int readFile(FILE *f, int *size, char *buffer){
|
|
||||||
int index = 0;
|
|
||||||
char c;
|
|
||||||
int end = 0;
|
|
||||||
|
|
||||||
do{
|
|
||||||
c = fgetc(f);
|
|
||||||
buffer[index] = c;
|
|
||||||
index++;
|
|
||||||
*size += 1;
|
|
||||||
|
|
||||||
// End of the file, we stop it
|
|
||||||
if (c == EOF){
|
|
||||||
buffer[index - 1] = '\0';
|
|
||||||
index = BUFFER_SIZE;
|
|
||||||
end = 1;
|
|
||||||
}
|
|
||||||
}while(index < BUFFER_SIZE);
|
|
||||||
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
s -> path source
|
s -> path source
|
||||||
d -> path destination
|
d -> path destination
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
int foo(FILE *, int *, char *);
|
|
||||||
int cryptCaesar(const char *, const char *, const int);
|
int cryptCaesar(const char *, const char *, const int);
|
||||||
int decryptCaesar(const char *, const char *, const int);
|
int decryptCaesar(const char *, const char *, const int);
|
||||||
|
|
||||||
|
|||||||
+25
-2
@@ -12,12 +12,35 @@ int fileExist(const char *path) {
|
|||||||
FILE *f=NULL;
|
FILE *f=NULL;
|
||||||
f=fopen(path,"r");
|
f=fopen(path,"r");
|
||||||
|
|
||||||
if(f==NULL){
|
if(f==NULL)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
This function read the file block by block until the end of it
|
||||||
|
*/
|
||||||
|
int readFile(FILE *f, int *size, char *buffer){
|
||||||
|
int index = 0;
|
||||||
|
char c;
|
||||||
|
int end = 0;
|
||||||
|
|
||||||
|
do{
|
||||||
|
c = fgetc(f);
|
||||||
|
buffer[index] = c;
|
||||||
|
index++;
|
||||||
|
*size += 1;
|
||||||
|
|
||||||
|
// End of the file, we stop it
|
||||||
|
if (c == EOF){
|
||||||
|
buffer[index - 1] = '\0';
|
||||||
|
index = BUFFER_SIZE;
|
||||||
|
end = 1;
|
||||||
|
}
|
||||||
|
}while(index < BUFFER_SIZE);
|
||||||
|
|
||||||
|
return end;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
path -> path source
|
path -> path source
|
||||||
This function copy all characters of the file in the buffer
|
This function copy all characters of the file in the buffer
|
||||||
|
|||||||
@@ -5,8 +5,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define BUFFER_SIZE 4096
|
||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
void usage();
|
void usage();
|
||||||
|
int readFile(FILE *, int *, char *);
|
||||||
int fileExist(const char *path);
|
int fileExist(const char *path);
|
||||||
int copyFile(const char *path, char *buffer);
|
int copyFile(const char *path, char *buffer);
|
||||||
int addDataToFile(const char *data, const char *path);
|
int addDataToFile(const char *data, const char *path);
|
||||||
|
|||||||
+19
-3
@@ -1,6 +1,7 @@
|
|||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "caesar.h"
|
#include "caesar.h"
|
||||||
#include "vigenere.h"
|
#include "vigenere.h"
|
||||||
|
#include "polybius.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
int error = 0;
|
int error = 0;
|
||||||
@@ -14,7 +15,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check kind of encryption
|
// Check kind of encryption
|
||||||
for(i = 0; i < 3; i++){
|
for(i = 0; i < 4; i++){
|
||||||
if(strcmp(argv[1], options[i]) == 0)
|
if(strcmp(argv[1], options[i]) == 0)
|
||||||
error++;
|
error++;
|
||||||
}
|
}
|
||||||
@@ -100,7 +101,24 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
// Polybius square
|
// Polybius square
|
||||||
else if(strcmp(argv[1], "-s") == 0){
|
else if(strcmp(argv[1], "-s") == 0){
|
||||||
|
char key[26];
|
||||||
|
int res;
|
||||||
|
|
||||||
|
printf("Your key: ");
|
||||||
|
scanf("%s", key);
|
||||||
|
|
||||||
|
if (strlen(key) > 26){
|
||||||
|
printf("Your key is too big. Choose a small one\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strcmp(hook, "crypt") == 0)
|
||||||
|
res = cryptPolybius(fileSrc, fileDst, key);
|
||||||
|
else
|
||||||
|
res = decryptPolybius(fileSrc, fileDst, key);
|
||||||
|
|
||||||
|
if (res != 0)
|
||||||
|
printf("Failed to crypt/decrypt the file\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Display error */
|
/* Display error */
|
||||||
@@ -111,7 +129,5 @@ int main(int argc, char *argv[]) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
free(fileDst);
|
free(fileDst);
|
||||||
//free(buffer);
|
|
||||||
//free(data);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
+174
@@ -0,0 +1,174 @@
|
|||||||
|
#include "polybius.h"
|
||||||
|
|
||||||
|
|
||||||
|
int cryptPolybius(const char *filenameSrc, const char *filenameDst, const char *key){
|
||||||
|
char polybius[POLYBIUS_SIZE][POLYBIUS_SIZE];
|
||||||
|
FILE *f = NULL, *fDst = NULL;
|
||||||
|
char data[BUFFER_SIZE];
|
||||||
|
char dataEncrypted[BUFFER_SIZE];
|
||||||
|
int size = 0, end = 0, i = 0, j = 0;
|
||||||
|
char c = 0;
|
||||||
|
|
||||||
|
generateSquarePolybius(polybius, key);
|
||||||
|
|
||||||
|
for (i = 0; i < POLYBIUS_SIZE; i++){
|
||||||
|
for (j = 0; j < POLYBIUS_SIZE; j++)
|
||||||
|
printf("%c ", polybius[i][j]);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
// Open the file
|
||||||
|
f = fopen(filenameSrc, "r+");
|
||||||
|
if (f == NULL) return -1;
|
||||||
|
|
||||||
|
fDst = fopen(filenameDst, "w");
|
||||||
|
if (fDst == NULL) {
|
||||||
|
fclose(f);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
end = readFile(f, &size, data);
|
||||||
|
|
||||||
|
/********* Encryption **********/
|
||||||
|
for (i = 0; i < size; i++){
|
||||||
|
if (data[i] >= 'a' && data[i] <= 'z')
|
||||||
|
c = data[i] - 32;
|
||||||
|
else c = data[i];
|
||||||
|
|
||||||
|
for (j = 0; j < POLYBIUS_SIZE; j++){
|
||||||
|
for (int x = 0; x < POLYBIUS_SIZE; x++){
|
||||||
|
if (c == polybius[j][x]){
|
||||||
|
fputc(j + '0', fDst);
|
||||||
|
fputc(x + '0', fDst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (c == '\n' || c == ' '){
|
||||||
|
fputc(c, fDst);
|
||||||
|
fputc(0, fDst); // For having a couple of number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size = 0;
|
||||||
|
memset(data, 0, BUFFER_SIZE);
|
||||||
|
memset(dataEncrypted, 0, BUFFER_SIZE);
|
||||||
|
}while(end != 1);
|
||||||
|
|
||||||
|
/* Close files */
|
||||||
|
fclose(f);
|
||||||
|
fclose(fDst);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int decryptPolybius(const char *filenameSrc, const char *filenameDst, const char *key){
|
||||||
|
char polybius[POLYBIUS_SIZE][POLYBIUS_SIZE];
|
||||||
|
FILE *f = NULL, *fDst = NULL;
|
||||||
|
char data[BUFFER_SIZE];
|
||||||
|
char dataEncrypted[BUFFER_SIZE];
|
||||||
|
int size = 0, end = 0, i = 0, j = 0;
|
||||||
|
|
||||||
|
generateSquarePolybius(polybius, key);
|
||||||
|
|
||||||
|
for (i = 0; i < POLYBIUS_SIZE; i++){
|
||||||
|
for (j = 0; j < POLYBIUS_SIZE; j++)
|
||||||
|
printf("%c ", polybius[i][j]);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
// Open the file
|
||||||
|
f = fopen(filenameSrc, "r+");
|
||||||
|
if (f == NULL) return -1;
|
||||||
|
|
||||||
|
fDst = fopen(filenameDst, "w");
|
||||||
|
if (fDst == NULL) {
|
||||||
|
fclose(f);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
end = readFile(f, &size, data);
|
||||||
|
|
||||||
|
/********* Decryption **********/
|
||||||
|
for (i = 0; i < size; i += 2){
|
||||||
|
if (data[i] >= 48 && data[i] <= 53) {
|
||||||
|
int c1 = data[i] - '0';
|
||||||
|
int c2 = data[i+1] - '0';
|
||||||
|
char c = polybius[c1][c2];
|
||||||
|
printf("%c", c);
|
||||||
|
fputc(c, fDst);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
printf("%c", data[i]);
|
||||||
|
fputc(data[i], fDst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size = 0;
|
||||||
|
memset(data, 0, BUFFER_SIZE);
|
||||||
|
memset(dataEncrypted, 0, BUFFER_SIZE);
|
||||||
|
}while(end != 1);
|
||||||
|
|
||||||
|
/* Close files */
|
||||||
|
fclose(f);
|
||||||
|
fclose(fDst);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
This function fill the polybius square
|
||||||
|
*/
|
||||||
|
static void fillSquare(int pos, int *posPolybius, char *p, char polybius[POLYBIUS_SIZE][POLYBIUS_SIZE]){
|
||||||
|
for (int i = 0; i < POLYBIUS_SIZE; i++){
|
||||||
|
polybius[pos][i] = p[*(posPolybius)];
|
||||||
|
*posPolybius = *posPolybius + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static int findKeyInSquare(const char *polybius, char c){
|
||||||
|
// We exclude the 'J' character
|
||||||
|
for (int i = 0; i < ALPHABET_SIZE - 1; i++)
|
||||||
|
if (c == polybius[i])
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
This function generate the polybius square
|
||||||
|
*/
|
||||||
|
void generateSquarePolybius(char polybius[POLYBIUS_SIZE][POLYBIUS_SIZE], const char *key){
|
||||||
|
char a[ALPHABET_SIZE - 1] = {0}; // The size is 25, we exclude the J character
|
||||||
|
|
||||||
|
int pos = 0;
|
||||||
|
for (int i = 0; i < strlen(key); i++){
|
||||||
|
char k;
|
||||||
|
if (key[i] >= 'a' && key[i] <= 'z')
|
||||||
|
k = key[i] - 32; // 32 = 26 + special characters
|
||||||
|
else k = key[i];
|
||||||
|
int res = findKeyInSquare(a, k);
|
||||||
|
if (res == 0)
|
||||||
|
a[pos++] = k;
|
||||||
|
}
|
||||||
|
int n = 0;
|
||||||
|
int t = pos;
|
||||||
|
for (int i = pos; i < ALPHABET_SIZE + pos; i++){
|
||||||
|
char c = 'A' + n;
|
||||||
|
if (c == 'J'){
|
||||||
|
// We check if I is in the array, if yes, we do not add it
|
||||||
|
}
|
||||||
|
/*if (c == 'I'){
|
||||||
|
// We check if J is in the array, is yes, we do not add it
|
||||||
|
int res = findKeyInSquare(a, 'J');
|
||||||
|
// J not in the array, we add it
|
||||||
|
if (res == 0){
|
||||||
|
a[t++] = 'A';
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
if (c != 'J'){
|
||||||
|
int res = findKeyInSquare(a, c);
|
||||||
|
|
||||||
|
if (res == 0)
|
||||||
|
a[t++] = c;
|
||||||
|
}
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
pos = 0;
|
||||||
|
fillSquare(0, &pos, a, polybius);
|
||||||
|
fillSquare(1, &pos, a, polybius);
|
||||||
|
fillSquare(2, &pos, a, polybius);
|
||||||
|
fillSquare(3, &pos, a, polybius);
|
||||||
|
fillSquare(4, &pos, a, polybius);
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef H_POLYBIUS
|
||||||
|
#define H_POLYBIUS
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "functions.h"
|
||||||
|
|
||||||
|
#define POLYBIUS_SIZE 5
|
||||||
|
#define ALPHABET_SIZE 26
|
||||||
|
|
||||||
|
int cryptPolybius(const char *, const char *, const char *);
|
||||||
|
int decryptPolybius(const char *, const char *, const char *);
|
||||||
|
void generateSquarePolybius(char polybius[5][5], const char *);
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in new issue
Block a user