Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Crypto-Phase-1 + UNIX-1 #148

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -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.

Original file line number Diff line number Diff line change
@@ -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

32 changes: 32 additions & 0 deletions RE-Cryptography/Sessions-5-&-6/Nakul/nakul-caesar_decryption.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
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);
}

42 changes: 42 additions & 0 deletions RE-Cryptography/Sessions-5-&-6/Nakul/nakul-caesar_encryption.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
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);

}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ktctkotl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tl�srttpdr
��
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
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);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
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);

}
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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.
55 changes: 55 additions & 0 deletions RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_decryption.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
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<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)%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);
}
64 changes: 64 additions & 0 deletions RE-Cryptography/Sessions-5-&-6/Nakul/nakul-vigener_encryption.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
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);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
charlotte
19 changes: 19 additions & 0 deletions UNIX/Nakul/assignment1.sh
Original file line number Diff line number Diff line change
@@ -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