Python Forum
how to generate sha256 hash for each line of my txt file | using python version 3.6.4
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to generate sha256 hash for each line of my txt file | using python version 3.6.4
#1
I am creating a project for generating sha256 hash from text file
I want to read each line from my text file and generate sha256 for it.

Here is the code i written but it is not correct. please see and suggest me.
my text file contains:
apple
banana
grape
watermelon
stawberry

my Code is :
import hashlib
f = open("D:/12/1.txt",'r')
x = f.readline()
while(x !=""):
    hash_object = hashlib.sha256(b'x')
    hex_dig = hash_object.hexdigest()
    print(x.strip(),"",hex_dig)
    x= f.readline()

input("Successful..Press enter to exit")
Reply


Messages In This Thread
how to generate sha256 hash for each line of my txt file | using python version 3.6.4 - by rajtekken5 - Feb-11-2018, 12:40 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  run part of a script with a different version of Python jdog 2 463 Jan-09-2024, 08:49 PM
Last Post: jdog
  How to find out from outside Python (in Windows) the current version of Python? pstein 4 756 Oct-04-2023, 10:01 AM
Last Post: snippsat
  Help with Python Script to generate SVG Dot Matrix Pattern for LED Light Guide iamrickm 2 774 Aug-25-2023, 06:07 PM
Last Post: iamrickm
  How to resolve version conflicts in Python? taeefnajib 0 940 Apr-27-2023, 08:37 PM
Last Post: taeefnajib
  [SOLVED] How to crack hash with hashlib Milan 0 1,425 Mar-09-2023, 08:25 PM
Last Post: Milan
  File "<string>", line 19, in <module> error is related to what? Frankduc 9 12,598 Mar-09-2023, 07:22 AM
Last Post: LocklearSusan
  Python venv and PIP version issue JanOlvegg 2 1,281 Feb-22-2023, 02:22 AM
Last Post: JanOlvegg
  Python Version upgrade nitinkukreja 1 914 Feb-04-2023, 10:27 PM
Last Post: Larz60+
  Getting last line of each line occurrence in a file tester_V 1 878 Jan-31-2023, 09:29 PM
Last Post: deanhystad
  Writing string to file results in one character per line RB76SFJPsJJDu3bMnwYM 4 1,394 Sep-27-2022, 01:38 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020