기본 숫자를 10 ^ 9 이상으로 늘리면 코드가 작동하지 않습니다. (Code fails to work when i increase the base numbers to anything over 10 ^ 9)


문제 설명

기본 숫자를 10 ^ 9 이상으로 늘리면 코드가 작동하지 않습니다. (Code fails to work when i increase the base numbers to anything over 10 ^ 9)

저는 소수인 두 개의 기본 숫자를 요구하는 RSA 암호화 프로그램을 작성 중입니다. 크면 클수록 좋습니다. 아래는 메소드의 코드입니다.

def PrimeNumber(self):
    number=random.randint(10**8, 10**9)
    while True:
        prime = self.PrimeTest(number)
        if prime:
            return number
        number+=1

이 형식의 코드는 완벽하게 작동하지만 난수 생성기를 변경하여 10 ^ 9보다 큰 숫자를 생성하면 암호 해독으로 이동할 때 코드가 더 이상 작동하지 않습니다. 아래 메시지(아래에서 수행 방법 설명)는 마사지를 암호화 및 암호 해독하는 데 사용하는 방법입니다.</ p>

def encryption(self,m):
c=1
y =self.publicKey[0]
d = self.publicKey[1]
m=m%y
for num in range (d):
c=((c*m)%y)
return c

def decryption(self,base):
total = 1
power = self.d
y = self.num
while power > 0:
r = power % 2
if r == 1:
total = (total base) % y
base = (base
base) % y
power = power// 2
return total
</code></pre>

이 함수는 서로 역이며 숫자가 10^9 이하일 때 다시 작동합니다. 메시지를 암호화하기 위해 문자열을 분리하고 문자를 ASCII 번호로 변경한 다음 해당 숫자를 암호화하고 해독을 위해 역순으로 수행합니다. RSA에 대해 잘 모르는 경우 RSA에 대한 간략한 설명입니다. <a href="https:/ /ko


참조 솔루션

(by M.Trossman)

참조 문서

  1. Code fails to work when i increase the base numbers to anything over 10 ^ 9 (CC BY‑SA 2.5/3.0/4.0)

#Python #cryptography #Encryption






관련 질문

Python - 파일 이름에 특수 문자가 있는 파일의 이름을 바꿀 수 없습니다. (Python - Unable to rename a file with special characters in the file name)

구조화된 배열의 dtype을 변경하면 문자열 데이터가 0이 됩니다. (Changing dtype of structured array zeros out string data)

목록 목록의 효과적인 구현 (Effective implementation of list of lists)

for 루프를 중단하지 않고 if 문을 중지하고 다른 if에 영향을 줍니다. (Stop if statement without breaking for loop and affect other ifs)

기본 숫자를 10 ^ 9 이상으로 늘리면 코드가 작동하지 않습니다. (Code fails to work when i increase the base numbers to anything over 10 ^ 9)

사용자 지정 대화 상자 PyQT5를 닫고 데이터 가져오기 (Close and get data from a custom dialog PyQT5)

Enthought Canopy의 Python: csv 파일 조작 (Python in Enthought Canopy: manipulating csv files)

학생의 이름을 인쇄하려고 하는 것이 잘못된 것은 무엇입니까? (What is wrong with trying to print the name of the student?)

다단계 열 테이블에 부분합 열 추가 (Adding a subtotal column to a multilevel column table)

여러 함수의 변수를 다른 함수로 사용 (Use variables from multiple functions into another function)

리프 텐서의 값을 업데이트하는 적절한 방법은 무엇입니까(예: 경사하강법 업데이트 단계 중) (What's the proper way to update a leaf tensor's values (e.g. during the update step of gradient descent))

Boto3: 조직 단위의 AMI에 시작 권한을 추가하려고 하면 ParamValidationError가 발생합니다. (Boto3: trying to add launch permission to AMI for an organizational unit raises ParamValidationError)







코멘트