encryption

How to encrypt a string using python Openssl public key?

How to encrypt a string using python Openssl public key? Question: My current code to generate an OpenSSL public-private key pair: import OpenSSL key = OpenSSL.crypto.PKey() key.generate_key(OpenSSL.crypto.TYPE_RSA, 2048) public_key = OpenSSL.crypto.dump_publickey(OpenSSL.crypto.FILETYPE_PEM, key) private_key = OpenSSL.crypto.dump_privatekey(OpenSSL.crypto.FILETYPE_PEM, key) print(public_key, private_key, sep="n") Asked By: Flow || Source Answers: The documentation recommends that you call key.to_cryptography_key() to get a …

Total answers: 1

How to salt a generated hash from a file in Python

How to salt a generated hash from a file in Python Question: Problem I wrote a function which signs an uploaded document. In order to increase the security of the function, I would like to add a SALT to it. As I am reading the bytes of the uploaded file, so I guess I would …

Total answers: 1

Sumation hash and key value in python

Sumation hash and key value in python Question: I try to sum hash + Key to gain new hash value. The key value: a= "111631279578723877696242174" The Hash Value by SHA-256: b = "7de8c9d1ce09fd2554fc0468ae52d5144800d3ae3ae9b075a3ba4494e5e55f50" My idea is to convert them to a binary value and sum the two but I got an error: V1= list(map(bin, bytearray(a, …

Total answers: 1

text crypter program dosent give right results

text crypter program dosent give right results Question: when you crypt a text it works but when you try to decrypt in it gives weird result. My code was working but it suddenly broke. The things is I don’t know if encrypting part or decrypting part is broken I would appreciate any help. import random …

Total answers: 1

Decrypt with Fernet, TypeError: token must be bytes

Decrypt with Fernet, TypeError: token must be bytes Question: Programming language: Python i have three files, one is to generate the key, 2nd is to encrypt, and the other is to decrypt.. the 1st and the 2nd files work.. but the decrypt file won’t work generate key file: from cryptography.fernet import Fernet def generate_key(): """ …

Total answers: 3

Python : name 'set_password' is not defined

Python : name 'set_password' is not defined Question: Im trying to register users hashing their passwords before add to database as follows settings.py PASSWORD_HASHERS = ( ‘django.contrib.auth.hashers.MD5PasswordHasher’, ) Models.py from django.contrib.auth.models import AbstractBaseUser class Users(AbstractBaseUser): name = models.CharField(max_length=200) email = models.CharField(max_length=200) password = models.CharField(max_length=255) Views.py name = form.cleaned_data.get(‘name’) email = form.cleaned_data.get(’email’) password = form.cleaned_data.get(‘password’) date_joined …

Total answers: 1

How to encrypt JSON in python

How to encrypt JSON in python Question: I have a JSON file. I am running a program, in python, where data is extracted from the JSON file. Is there any way to encrypt the JSON file with a key, so that if someone randomly opens the file, it would be a mess of characters, but …

Total answers: 3

Is it possible to save a fernet key for a later session?

Is it possible to save a fernet key for a later session? Question: I am very new at python, I was working on a program that encrypts a text string, then saves it to a file. My program works perfectly when I encrypt then decrypt it in the same session. What I would like to …

Total answers: 2