Skip to main content

Featured

Python To read the news

Hello Guys, in this blog we will use Python to read the news. Before this, the concepts of APIs, JSON, Python Libraries should be clear. We are going to use 'newsdataapi' library of Python. The newsdataapi is the official Python client library for the Newsdata.io API. Its primary purpose is to simplify the process of accessing global news data directly from Newsdata.io, allowing developers to integrate news content into their applications without having to manually construct HTTP requests. It acts as a wrapper around the API, handling the complexities of authentication, request parameters, and response parsing. So Lets Start. Making Python to read the online news Step 1: Get your API key Sign Up : Go to the Newsdata.io website and create a free account. The free plan typically offers a limited number of credits per day (e.g., 200 credits). Get the Key : Once you've created and verified your account, your unique API key will be available on your dashboard. Copy this key,...

Hashing

 Hashing is the process which converts a simple plain text into a text which is not the same text entered. You can think like that after hashing the text is now with mix letters which does not make any sense. Hashing is an algorithm that is used for keeping password database so that if a hacker hacks your database than hacker cannot know the password because it is not password it is hash.

There are many hashing algorithm like md-5, sha256, RSA etc. Hashing algorithm is an encryption algorithm. In different programming language we can convert a word or phrase into hash so that we can keep the word or phrase secret. You know that password is very important because much people sign in in different website. If there password is strong than while converting into simple text it can take lots of time to know. Which means that your password is very secure and strong. 

In different programming the way of writing the program for converting a text into hash may be different but at last we get the output same. For example: 

In python if make a program to convert the phrase 'Hello world' into md5 hash it will give result 3e25960a79dbc69b674cd4ec67a72c62. And If you wish to try in php language it also going to give you same result because word is same 'Hello world'. The syntax comparison is given below:

In Python

import hashlib

result = hashlib.md5(b'Hello world')

print(result.hexdigest())


Output: 3e25960a79dbc69b674cd4ec67a72c62


In Php

<?php

$str = "Hello world";

$a = "3e25960a79dbc69b674cd4ec67a72c62";

echo md5($str);

?>

Output:

3e25960a79dbc69b674cd4ec67a72c62


Here both the result is same. But in case of bcrypt means blowfish algorithm every time you run the program you are going to get new hash for same word or phrase. For example if the run the program that converts "New things to know" into hash and show the hash as output than the first result might show '$2b$12$/LHdmOpjLcK0cOI4KFIJees8YB0K7IJdkTreRQfLlAnSP1VUNgJma', another ''$2b$12$AeUG/6cJL8gepOTphLazBud/Os4tKdZVRrovGscn2qHMqLJhWW.kq".

In python the program is made like this. Code:

import bcrypt

phrase = b"New things to know"

hashed = bcrypt.hashpw(phrase, bcrypt.gensalt())

print(hashed.decode('utf-8'))


Just I want to tell is that it returns different hash for same phrase if it run many times.


Comments

Popular Posts