diff --git a/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-caesar_ciphertext.txt b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-caesar_ciphertext.txt new file mode 100644 index 0000000..83f1612 --- /dev/null +++ b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-caesar_ciphertext.txt @@ -0,0 +1,2 @@ +d gudjrqeruq lv d pruwdo pdq ru zrpdq eruq zlwk wkh vrxo ri d gudjrq.lw hqdeohv wkhp wr xvh wkh gudjrq'v delolwb wr devrue d vodlq gudjrq'v vrxo wr uhfhlyh nqrzohgjh ri wkh wkx'xp, udwkhu wkdq kdylqj wr ohduq wkurxjk sudfwlfh.vw. dohvvld zdv wkh iluvw shuvrq wr eh dvvrfldwhg zlwk wkh wlwoh gudjrqeruq.vkh lv eholhyhg wr kdyh jdlqhg wkh eorrg ri d gudjrq diwhu pdnlqj d fryhqdqw zlwk dndwrvk wr vhdo wkh jdwhv ri reolylrq. vlqfh wkhq, wkhuh kdyh ehhq pdqb wdohv ri khurhv ri wkh gudjrqv eorrg zkr zrxog nloo gudjrqv dqg vwhdo wkhlu srzhu. wkh delolwb wr devrue gudjrq vrxov fdph iluvw wr wkh gudjrq sulhvw pluddn. diwhuzdugv, doo nqrzq gudjrqeruqv frxog ohduq srzhuixo vkrxwv pxfk txlfnhu wkdq rwkhu pruwdov, zkr uhtxluh bhduv ri phglwdwlrq wr pdvwhu wkhp. + \ No newline at end of file diff --git a/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-caesar_decrypted.txt b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-caesar_decrypted.txt new file mode 100644 index 0000000..d888e4d --- /dev/null +++ b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-caesar_decrypted.txt @@ -0,0 +1,2 @@ +modern cryptography is heavily based on mathematical theory and computer science practice cryptographic algorithms are designed around computational hardness assumptions making such algorithms hard to break in practice by any adversary it is theoretically possible to break such a system but it is infeasible to do so by any known practical means these schemes are therefore termed computationally secure theoretical advances eg improvements in integer factorization algorithms and faster computing technology require these solutions to be continually adapted there exist information0theoretically secure schemes that probably cannot be broken even with unlimited computing power an example is the one time pad but these schemes are more difficult to implement than the best theoretically breakable but computationally secure mechanisms + \ No newline at end of file diff --git a/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-caesar_decryption.c b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-caesar_decryption.c new file mode 100644 index 0000000..90afe4e --- /dev/null +++ b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-caesar_decryption.c @@ -0,0 +1,32 @@ +#include +#include +#include +void main(){ +char ct[1000],pt[1000]; +FILE *f1; +f1=fopen("nakul-caesar_encoded.txt","r"); +if(f1==NULL) + {printf("can't access file\n"); + exit(0); + } +fgets(pt,1000,f1); +fclose(f1); +int i; +for(i=0;pt[i]!='\0';i++) + {if(pt[i]>=97&&pt[i]<=122) + { pt[i]-=97; + ct[i]=(pt[i]+23)%26 +97; + } + else + ct[i]=pt[i]; + } +FILE *f2; +f2=fopen("nakul-caesar_decrypted.txt","w"); +if(f2==NULL) + {printf("can't access file\n"); + exit(0); + } +fputs(ct,f2); +fclose(f2); +} + diff --git a/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-caesar_encryption.c b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-caesar_encryption.c new file mode 100644 index 0000000..8997716 --- /dev/null +++ b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-caesar_encryption.c @@ -0,0 +1,42 @@ +#include +#include +#include +void main(){ +char ct[1000],pt[1000]; + +FILE *f1; +f1 = fopen("nakul-caesar_message.txt","r"); + if(f1==NULL) + { + printf("can't access file\n"); + exit(0); + } +fgets(pt,1000,f1); +fclose(f1); + + +int i; +for(i = 0; pt[i] != '\0'; i++) + { + if(pt[i] >= 97 && pt[i] <= 122) + { + pt[i] -= 97; + ct[i] = (pt[i] + 3)%26 +97; + } + else + ct[i] = pt[i]; + } + + +FILE *f2; +f2=fopen("nakul-caesar_ciphertext.txt","w"); + if(f2==NULL) + { + printf("can't access file\n"); + exit(0); + } +fputs(ct,f2); +fclose(f2); + +} + diff --git a/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-substitution_ciphertext.txt b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-substitution_ciphertext.txt new file mode 100644 index 0000000..5b87cf0 --- /dev/null +++ b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-substitution_ciphertext.txt @@ -0,0 +1 @@ +ktctkotl diff --git a/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-substitution_decrypted.txt b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-substitution_decrypted.txt new file mode 100644 index 0000000..47425db --- /dev/null +++ b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-substitution_decrypted.txt @@ -0,0 +1,2 @@ +tlŒsrttpdr +úÿ \ No newline at end of file diff --git a/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-substitution_decryption.c b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-substitution_decryption.c new file mode 100644 index 0000000..dd7b95d --- /dev/null +++ b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-substitution_decryption.c @@ -0,0 +1,49 @@ +#include +#include +#include +void main(){ +char ct[1000],pt[1000],k[26]; + +FILE *f1; +f1=fopen("akash-substitution_ciphertext.txt","r"); + if(f1==NULL) + { + printf("can't access file\n"); + exit(0); + } +fgets(ct,1000,f1); +fclose(f1); + + +FILE *fk; +fk=fopen("akash-substitution_key.txt","r"); +if(fk==NULL) + {printf("can't access file\n"); + exit(0); + } +fgets(k,27,fk); +fclose(fk); + +printf("%s\n",k); +int i; +for(i=0;ct[i]!='\0';i++) + {if(ct[i]>=97&&ct[i]<=122) + { int a; + char c=ct[i]; + for(a=0;c!=k[a];a++) + pt[i]=97+a; + } + else + pt[i]=ct[i]; +} + +printf("%s\n",pt); +FILE *f2; +f2=fopen("nakul-substitution_decrypted.txt","w"); +if(f2==NULL) + {printf("can't access file\n"); + exit(0); + } +fputs(pt,f2); +fclose(f2); +} diff --git a/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-substitution_encryption.c b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-substitution_encryption.c new file mode 100644 index 0000000..5323291 --- /dev/null +++ b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-substitution_encryption.c @@ -0,0 +1,50 @@ +#include +#include +#include +void main(){ +char ct[1000],pt[1000],k[26]; +FILE *f1; +f1 = fopen("nakul-substitution_message.txt","r"); + if(f1==NULL) + { + printf("can't access file\n"); + exit(0); + } +fgets(pt,1000,f1); +fclose(f1); + +FILE *fk; +fk = fopen("nakul-substitution_Key.txt","r"); + if(fk==NULL) + { + printf("can't access file\n"); + exit(0); + } +fgets(k,26,fk); +fclose(fk); + + +int i; +for(i = 0; pt[i] != '\0'; i++) + { + if(pt[i] >= 97 && pt[i] <= 122) + { + int a = pt[i]-97; + ct[i] = k[a]; + } + else + ct[i] = pt[i]; + } + + +FILE *f2; +f2 = fopen("nakul-substitution_ciphertext.txt","w"); + if(f2==NULL) + { + printf("can't access file\n"); + exit(0); + } +fputs(ct,f2); +fclose(f2); + +} diff --git a/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_ciphertext.txt b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_ciphertext.txt new file mode 100644 index 0000000..ef995a7 --- /dev/null +++ b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_ciphertext.txt @@ -0,0 +1 @@ +dvjrny aeu frwzxg kutf o vcppcrw wxttlsjpr emhl fq vhyeo ctjbgk dhzws pevjhzyu kitbnj cy lkz ylg-uigu jscp. yoicp lmeapnx oehrg hv vhlxu a aokmc dhvcs ai teveg msfk tsooxd, a jcngk zlrnyxk ohn hvh rgcei zxtzgz ytg aswze lbw fgjodpg uslhcb'g hrnf wcwxgh. hv ovmycslp qtkiu ffc mhhf, upgibxg srjwgz qahvckbli. hv rbwr'a nlbm xqkd ec eicce swf, hvr qstk qm czbxemplsj, tgh zaszhtzif hzd khgm ogpft. diff --git a/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_decrypted.txt b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_decrypted.txt new file mode 100644 index 0000000..258ca80 --- /dev/null +++ b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_decrypted.txt @@ -0,0 +1 @@ +as another day of fantasy plays out in westworld - a vast, remote park where guests pay top dollar to share wild-west adventures with android "hosts" - top programmer bernard lowe alerts park founder dr. robert ford, about incidents of aberrant behavior cropping up in some recently re-coded hosts. meanwhile in the town of sweetwater, a rancher's daughter named dolores encounters a gunslinger named teddy in the street - but their predictable narrative is upended by the appearance of a ruthless man in black and, later, by a supporting host's unscripted encounter with an artifact of the outside world. diff --git a/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_decryption.c b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_decryption.c new file mode 100644 index 0000000..d86d5bd --- /dev/null +++ b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_decryption.c @@ -0,0 +1,55 @@ +#include +#include +#include +void main(){ +char ct[1000],pt[1000],key[1000],k[1000]; +FILE *f1,*fp,*f2; + +f1=fopen("akash-vigener_ciphertext.txt","r"); +if(f1==NULL) + {printf("can't access file\n"); + exit(0); + } +fgets(pt,1000,f1); +fseek(f1,0,2); +long int len=ftell(f1); + + +fp=fopen("akash-vigener_keyfile.txt","r"); +if(fp==NULL) + {printf("can't access file\n"); + exit(0); + } +fgets(k,1000,fp); +int i,j; +int key_length=strlen(k); +for(i=0,j=0;i=97&&pt[j]<=122) + { pt[j]-=97; + key[j]-=97; + ct[j]=(pt[j]-key[j]+26)%26 +97; + } + else + ct[j]=pt[j]; + } + + +f2=fopen("nakul-vigener_decrypted.txt","w"); +if(f2==NULL) + {printf("can't access file\n"); + exit(0); + } +fputs(ct,f2); +fclose(fp); +fclose(f2); +fclose(f1); +} diff --git a/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_encryption.c b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_encryption.c new file mode 100644 index 0000000..c7f398f --- /dev/null +++ b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_encryption.c @@ -0,0 +1,64 @@ +#include +#include +#include +void main(){ +char ct[1000],pt[1000],key[1000],k[1000]; +FILE *f1,*fp,*f2; + +f1 = fopen("nakul-vigener_message.txt","r"); + if(f1==NULL) + { + printf("can't access file\n"); + exit(0); + } +fgets(pt,1000,f1); +fseek(f1,0,2); +long int len = ftell(f1); + + +fp=fopen("nakul-vigener_keyfile.txt","r"); +if(fp==NULL) + { + printf("can't access file\n"); + exit(0); + } +fgets(k,1000,fp); + +int i,j; +int key_length = strlen(k); + +for(i = 0, j = 0; i < len; i++, j++) + { + if(j == key_length-1) + j = 0; + key[i] = k[j]; + } +key[i] = '\0'; + + +for(j = 0; pt[j] != '\0' ; j++) + { + if(pt[j] >= 97 && pt[j] <= 122) + { + pt[j] -= 97; + key[j] -=97; + ct[j] = (pt[j] + key[j]) %26 +97; + } + else + ct[j]=pt[j]; + } + + +f2 = fopen("nakul-vigener_ciphertext.txt","w"); + if(f2==NULL) + { + printf("can't access file\n"); + exit(0); + } +fputs(ct,f2); + +fclose(fp); +fclose(f2); +fclose(f1); + +} diff --git a/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_keyfile.txt b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_keyfile.txt new file mode 100644 index 0000000..eeaca8b --- /dev/null +++ b/RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_keyfile.txt @@ -0,0 +1 @@ +charlotte diff --git a/UNIX/Nakul/assignment1.sh b/UNIX/Nakul/assignment1.sh new file mode 100755 index 0000000..9e2ff28 --- /dev/null +++ b/UNIX/Nakul/assignment1.sh @@ -0,0 +1,19 @@ +#!/bin/bash +echo enter 3 nos +read a b c +if [ $a -gt $b ] + then + if [ $a -gt $c ] + then + echo $a is the greatest + else + echo $c is the greatest + fi +elif [ $b -gt $c ] + then + echo $b is the greatest + else + echo $c is the greatest +fi +d=$((a+b+c)) +echo sum= $d