Commit 24c5e226 authored by SHIVAM SOOD's avatar SHIVAM SOOD

Complete

parent f8fc9ca1
// gcc program1.c -o program1 -lssl
#include <stdio.h>
#include <string.h>
#include <openssl/md5.h>
int main()
{
unsigned char digest[MD5_DIGEST_LENGTH];
char string[] = "happy";
MD5((unsigned char*)&string, strlen(string), (unsigned char*)&digest);
char mdString[33];
for(int i = 0; i < 16; i++)
sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]);
printf("md5 digest: %s\n", mdString);
return 0;
}
\ No newline at end of file
Office Order
Permission granted to Agent Z for procument of 100 desktop computers for the organization.
- Gabbar
hello how are you whats up dude Z to enter high security area
import sys
import hashlib as hashl
f1 = open("doc1.txt", "r+", encoding = 'utf-8')
f2 = open("doc2.txt", "r+", encoding = 'utf-8')
L = str(f1.read())
M = str(f2.read())
Listofhashes = []
for i in range(10):
#hd1 = hashl.md5(L)
hd1 = hashl.md5(L.encode('utf-8'))
s = str(hd1.hexdigest())[:2]
Listofhashes.append(s)
L = L + " "
d = 0
print(Listofhashes)
while True:
d+=1
hd2 = hashl.md5(M.encode('utf-8'))
z= str( hd2.hexdigest())[:2]
print(z)
if z in Listofhashes:
print(d)
break
M = M + " "
\ No newline at end of file
import sys
import hashlib as hashl
f1 = open("doc1.txt", "r+", encoding = 'utf-8')
f2 = open("doc2.txt", "r+", encoding = 'utf-8')
L = str(f1.read())
M = str(f2.read())
hd1 = hashl.md5(L.encode('utf-8'))
hd2 = hashl.md5(M.encode('utf-8'))
d = 0
test =str(hd1.hexdigest())[:2]
print(test)
while True:
L = L + " "
hd2 = hashl.md5(L.encode('utf-8'))
d+=1
Y = str(hd2.hexdigest())[:2]
if Y == test:
print(d)
break
This diff is collapsed.
Prac 1 - freq analysis
sed 's/old/new/g' file_name > outfile
sed -i 's/old/new/g' file_name //For updating in new file
Prac 2- vigenere
prac3- openssl
AES encrytpion
openssl enc -aes-128-cbc -e -in plain.txt -out cipher.bin -K 00112233445566778889aabbccddeeff -iv 0102030405060708;
Open Encrypted image file:
head -c 54 plain.bmp > header" ; "tail -c +55 cipher.bmp > body" ; "cat header body > new.bmp"
AES Decryption
openssl aes-128-cbc -d -in cipher.bin -out plain.txt -K 00112233445566778889aabbccddeeff -iv 0102030405060708;
DES encryption
openssl enc -des-ecb -K e0e0e0e0f1f1f1f1 -in mesg.plain -out mesg.enc
DES encryption
openssl des-ecb -d -K e0e0e0e0f1f1f1f1 -in mesg.plain -out mesg.enc
prac4-
This diff is collapsed.
import sys
dict_char = {}
with open(sys.argv[1], 'r') as f:
for line in f:
for c in line:
if c not in dict_char.keys():
dict_char[c] = 1
else:
dict_char[c] += 1
l = sorted( dict_char.items(), key = lambda key_val : (key_val[1], key_val[0]) , reverse=True)
for items in l:
print(str(items[0]) + ' '+str(items[1]))
#print(dict_char)
Office Order
Permission granted to Agent Z for procument of 100 desktop computers for the organization.
- Gabbar
hello how are you whats up dude Z to enter high security area
import sys
import hashlib as hashl
f1 = open("doc1.txt", "r+", encoding = 'utf-8')
f2 = open("doc2.txt", "r+", encoding = 'utf-8')
L = str(f1.read())
M = str(f2.read())
Listofhashes = []
for i in range(10):
#hd1 = hashl.md5(L)
hd1 = hashl.md5(L.encode('utf-8'))
s = str(hd1.hexdigest())[:2]
Listofhashes.append(s)
L = L + " "
d = 0
print(Listofhashes)
while True:
d+=1
hd2 = hashl.md5(M.encode('utf-8'))
z= str( hd2.hexdigest())[:2]
print(z)
if z in Listofhashes:
print(d)
break
M = M + " "
\ No newline at end of file
import sys
import hashlib as hashl
f1 = open("doc1.txt", "r+", encoding = 'utf-8')
f2 = open("doc2.txt", "r+", encoding = 'utf-8')
L = str(f1.read())
M = str(f2.read())
hd1 = hashl.md5(L.encode('utf-8'))
hd2 = hashl.md5(M.encode('utf-8'))
d = 0
test =str(hd1.hexdigest())[:2]
print(test)
while True:
L = L + " "
hd2 = hashl.md5(L.encode('utf-8'))
d+=1
Y = str(hd2.hexdigest())[:2]
if Y == test:
print(d)
break
openssl command [ command_opts ] [ command_args ]
openssl [ list-standard-commands | list-message-digest-commands | list-
cipher-commands | list-cipher-algorithms | list-message-digest-
algorithms | list-public-key-algorithms]
openssl no-XXX [ arbitrary options ]
dgst Message Digest Calculation.
dhparam Generation and Management of Diffie-Hellman Parameters.
Superseded by genpkey and pkeyparam
genpkey Generation of Private Key or Parameters.
passwd Generation of hashed passwords.
rand Generate pseudo-random bytes.
x509 X.509 Certificate Data Management.
MESSAGE DIGEST COMMANDS
md2 MD2 Digest
md5 MD5 Digest
mdc2 MDC2 Digest
rmd160 RMD-160 Digest
sha SHA Digest
sha1 SHA-1 Digest
sha224 SHA-224 Digest
sha256 SHA-256 Digest
sha384 SHA-384 Digest
sha512 SHA-512 Digest
ENCODING AND CIPHER COMMANDS
base64 Base64 Encoding
bf bf-cbc bf-cfb bf-ecb bf-ofb
Blowfish Cipher
cast cast-cbc
CAST Cipher
cast5-cbc cast5-cfb cast5-ecb cast5-ofb
CAST5 Cipher
des des-cbc des-cfb des-ecb des-ede des-ede-cbc des-ede-cfb des-ede-ofb
des-ofb
DES Cipher
des3 desx des-ede3 des-ede3-cbc des-ede3-cfb des-ede3-ofb
Triple-DES Cipher
idea idea-cbc idea-cfb idea-ecb idea-ofb
IDEA Cipher
rc2 rc2-cbc rc2-cfb rc2-ecb rc2-ofb
RC2 Cipher
rc4 RC4 Cipher
rc5 rc5-cbc rc5-cfb rc5-ecb rc5-ofb
RC5 Cipher
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment