# Reading the contents of a file and using it as an argument in Python

W

#### Wallace Souza

##### Guest
Wallace Souza Asks: Reading the contents of a file and using it as an argument in Python
I'm learning about hashing and I'm trying to do the following:

• Read the contents of a file
• Each line has a password, and I would like to use the crypt function to salt encode the password and compare it to the hash I have.

My code:

Code:
#!/usr/bin/python
import crypt
import sys

#       The password is 123456789 and the salt $1$1234$# Hash$1$1234$iePzeiQ11EHTph.AjL0GM.

hash = r"$1$1234$iePzeiQ11EHTph.AjL0GM." salt = r"$1$1234$"

with open('wl.txt') as file:
print newhash

if (newhash == hash):
else:
print "Password not found!"

Exit:

Code:
┌──(nag㉿kali)-[~]
└─$python2 hash.py Trying ...: 123456$1$1234$8acUSdjZh2kFpS8HkRvvD1
Trying ...: aaa

$1$1234$anGF2igSbkWXaDyzTS3PS. Password not found! Trying ...: bbb$1$1234$PHMaanM3Bt1Xuq8nx0eDu/
Trying ...: ccc

$1$1234$UyV97kO.cYwUbb3aC3x9d. Password not found! Trying ...: ddd$1$1234$Ej0sL587fdyknWC7zJBrG/
Trying ...: eee

$1$1234$7fNlaEimk/x0WCNcHpkIi. Password not found! Trying ...: 123456789$1$1234$MwVqxKiIuhUo7IeS3fMCt0
Password not found!

Questions:

1. I can't get the first line to show the password hash.
2. Why is there always a blank line between passwords?
3. My if is all messed up and I don't think it even works right. I would like to make him better.
4. Why are the hash generated by the script not the same as the one generated by python or Openssl?
5. I would like the "Password not found" to appear only once when I finish running the script. How do I do this?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

#### Custom loss function for regression

Filip Asks: Custom loss function for regression
I am trying to write a custom loss function for a machine learning regression task. What I want to accomplish is following:

• Reward higher preds, higher targets
• Punish higher preds, lower targets
• Ignore lower preds, lower targets
• Ignore lower preds, higher targets

All ideas are welcome, pseudo code or python code works good for me.

This is what I tried so far, it does not work so well I think it is because it does not take high targets into account (just high preds):

Code:
def mae_high(inp, targ):
inp, targ = flatten_check(inp, targ)
thresh = np.percentile(inp.detach().numpy(), 50)
return torch.abs(high_preds - high_targ).mean()

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

#### How would I prove this?

alwayscurious Asks: How would I prove this?
if there is a polynomial-time, additive 80-approximation algorithm for the Minimum Vertex Cover problem, then P = NP.

What i am thinking is, since we already know that the Min vertex cover + 80 vertices which spans vertex cover can be solved in polynomial time and then we need to find V-80 vertices from V ( V is total number of vertices in vertex cover) which is also vertex cover. this can also be done in polynomial time. Therefore the Min. Vertex Cover Problem can be solved in polynomial time. Therefore, P=NP.

I feel like this is wrong explanation. Any help is appreciated.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

#### [Solved] how to avoid too curly contours in QGIS?

Usha Asks: how to avoid too curly contours in QGIS?
I had point data in DXF and generated contours using QGIS. The contours had smaller islands and the contours in itself are too curly. I smoothed the contours too and I could avoid those unwanted island by rejecting contours of certain length but how to avoid unwanted curliness in the single elevation contour. I am very new to QGIS and I don't know python too. I have attached an image of part of my contour here. I have marked the curly contours with blue while I expect them to be straight like marked in red.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, solveforum.

#### [Solved] SearchCursor in arcpy, help!

Hannah Asks: SearchCursor in arcpy, help!
I'm pretty new to programming and am blocked on the correct way to format a SearchCursor that I need. I've attached a subset of my data below. I'm looking for a way to get arcpy to print out a list of counties(Adams, Alamosa, etc.) for each species if the cell value is equal to a 4 or 5. I'm pretty stuck on the correct wording and syntax to use to get it to print out a list of field names based on an integer cell value as well as the species name. Any help would be great!

I also attached a screenshot of my current code.... it's definitely all sorts of wrong but I'm not sure where to go next.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, solveforum.

#### [Solved] Color gradient in raster symbology using ArcGIS Pro

I'm using ArcGIS Pro 2.8. I have a raster, shown below, whose data I would like to show in a smooth, detailed manner, like in the second raster shown. I recognize that the second raster has a much smaller range (the first one has a range of about 713-1363, while the second has a range of 1-353).

Is there a way for me to show the detail in the first raster?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, solveforum.

#### The car continues clicking when the key is turned, but the car would not start

• jeffrey
• Physics
• Replies: 0
jeffrey Asks: The car continues clicking when the key is turned, but the car would not start
The car continues clicking when the key is turned, but the car would not start..

#### Suppose $G=\left\langle x, y, t|x^7=y^7=t^3=1, txt^{-1}=x^2, tyt^{-1}=y\right\rangle$. Show that $y\in Z(G)$.
Dick Grayson Asks: Suppose $G=\left\langle x, y, t|x^7=y^7=t^3=1, txt^{-1}=x^2, tyt^{-1}=y\right\rangle$. Show that $y\in Z(G)$.
The Problem: Suppose $G=\left\langle x, y, t|x^7=y^7=t^3=1, txt^{-1}=x^2, tyt^{-1}=y\right\rangle$. Show that $y\in Z(G)$.
My Attempt: Clearly $y$ commutes with $t$, so $y$ commutes with $t^2$ as well. Thus to show $y\in Z(G)$, it suffices to show that $y$ commutes with $x$. But I struggle to prove that $xy=yx$. It seems a rather silly place to get stuck-any HINT would be greatly appreciated.