Posts

Showing posts from March, 2019

Sample Blockchain using Python & Flask

# Importing the required libraries import datetime import hashlib import json from flask import Flask, jsonify # Building a sample Blockchain class Blockchain:     def __init__(self):         self.chain = []         self.createBlock(nonce = 1, previousHash = '0')     def createBlock(self, nonce, previousHash):         block = {'index': len(self.chain) + 1,                  'timestamp': str(datetime.datetime.now()),                  'nonce': nonce,                  'previousHash': previousHash}         self.chain.append(block)         return block     def getPreviousBlock(self):         return self.chain[-1]     def proofOfWork(self, previousnonce):       ...

Using Hashing Algorithms

import hashlib data=input("Enter data to encrypt ") a=hashlib.md5(data.encode()).hexdigest() b=hashlib.sha1(data.encode()).hexdigest() c=hashlib.sha256(data.encode()).hexdigest() d=hashlib.sha512(data.encode()).hexdigest() print(a,len(a)) print(b,len(b)) print(c,len(c)) print(d,len(d)) Enter data to encrypt 1234 81dc9bdb52d04dc20036dbd8313ed055 32 7110eda4d09e062aa5e4a390b0a572ac0d2c0220 40 03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4 64 d404559f602eab6fd602ac7680dacbfaadd13630335e951f097af3900e9de176b6db28512f2e000b9d04fba5133e8b1c6e8df59db3a8ab9d60be4b97cc9e81db 128

Using textblob library to detect a language and translate

Image