1 ~ 4 자 사이의 알파벳 문자열을 찾고 싶습니다.여러 개의 문자 목록을 순서대로 반복하십시오.
나는 52 개 문자의 목록을 반복하는 것으로 시작 :
letters = string.ascii_letters
그때 내가 찾고 있어요 문자열을 찾을 때까지 문자열의 다음 3 자에 대해 동일한 목록을 반복해야합니다.
_
_ _
_ _ _
_ _ _ _
어떻게 최적의 구조 루프의 일련의이 작업을 수행하는 것입니다 : 각 _ 52 개 문자의 목록을 나타내는 경우 각 반복에서 일치를 확인하는 동안
, 나는 기본적으로이 작업을 수행 할 필요가?
질문의 전제가 혼란 스러울 경우, 이는 무차별 균열에 관한 문제입니다. 나는 단순히 내가 고민하고있는 질문의 일부를 추출했다.
편집 : 여기까지 가야합니다. 이 아마도 같은
#we know the salt is the 2-digit '50'
#we know the key is limited to 4 alphabetical letters
#cycle through all possibilities of the key till we match the hash
letters = string.ascii_letters
lcounter = 0
i = 0
j = 0
k = 0
l = 0
tryhash = "a"
word = [letters[i]]
while(tryhash != hash):
for c in letters:
word = [letters[i]] #this does not work as the additional letters need to be appended to word after the first lcounter loop
tryword = ''.join(word)
tryhash = crypt.crypt(tryword, "50")
if (tryhash == hash):
print(word)
break
i += 1
if (lcounter > 0) and (i == 52):
i = 0
if (lcounter == 1) and (j == 0):
word.insert(lcounter, letters[j])
j += 1
if (lcounter > 1) and (k == 52):
j = 0
if (lcounter == 2) and (k == 0):
word.insert(lcounter, letters[k])
k += 1
if (lcounter > 2) and (k == 52):
k = 0
if (lcounter == 3) and (l == 0):
word.insert(lcounter, letters[l])
l += 1
lcounter += 1
에 오신 것을 환영합니다 SO Kyap에! 우리가 기꺼이 도와 드리 겠지만, 먼저 무엇을했는지 우리에게 보여줘야합니다. SO는 (보통) 코드 작성 서비스가 아닙니다. – AlG
예제 데이터 또는 의사 코드를 포함 할 수 있습니까? 질문을 읽는 데 문제가 있습니다. –
http://stackoverflow.com/questions/7074051/what-is-the-best-way-to-generate-all-possible-three-letter-strings을 참조하십시오. – kennytm