“enkripsi menggunakan python” Kode Jawaban

Python RSA

import Crypto
from Crypto.PublicKey import RSA
from Crypto import Random

random_generator = Random.new().read
key = RSA.generate(1024, random_generator) #generate public and private keys

publickey = key.publickey # pub key export for exchange

encrypted = publickey.encrypt('encrypt this message', 32)
#message to encrypt is in the above line 'encrypt this message'

print 'encrypted message:', encrypted #ciphertext

f = open ('encryption.txt', 'w'w)
f.write(str(encrypted)) #write ciphertext to file
f.close()

#decrypted code below

f = open ('encryption.txt', 'r')
message = f.read()

decrypted = key.decrypt(message)

print 'decrypted', decrypted

f = open ('encryption.txt', 'w')
f.write(str(message))
f.write(str(decrypted))
f.close()
Mysterious Mallard

enkripsi menggunakan python

#Made by myself

import random

text = input ( "Enter text: " )

result = ""
private_key = ""

for i in text:

    rand = random.randint ( 1, 125 )
    en = rand + ord ( i )
    en = chr ( en )
    en = str ( en )

    private_key = private_key + str ( rand ) + " "

    result = result + en

print ( "\nPublic key:", result )
print ( "Private key:", private_key )
Cooperative Cardinal

Jawaban yang mirip dengan “enkripsi menggunakan python”

Pertanyaan yang mirip dengan “enkripsi menggunakan python”

Lebih banyak jawaban terkait untuk “enkripsi menggunakan python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya