Answer the question
In order to leave comments, you need to log in
How to generate psk key?
I need to generate a psk key. It can be generated with the wpa_passphrase "ssid" "passwd" command.
But do I need to do it in python ?
import os
import sys
import re
from subprocess import Popen, PIPE
ssid = sys.argv[1]
passwd= sys.argv[2]
command = """ wpa_passphrase "%s" "%s" """ % (ssid , passwd)
proc = Popen(
command,
shell = True,
stdout=PIPE,stderr = PIPE
)
proc.wait()
res = proc.communicate()
result = res[0]
psk = re.findall("[a-f0-9]"*64,result)[0]
print(psk)
Answer the question
In order to leave comments, you need to log in
PSK = PBKDF2 (HMAC-SHA1, passwd, ssid, 4096, 256)
PBKDF2 appeared in the hashlib library since version 3.4, for it:
psk = hashlib.pbkdf2_hmac('sha1', passwd, ssid, 4096, 256)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question