Questions tagged [fernet]

Fernet is a protocol for symmetric encryption providing integrity / authentication, a set of encryption libraries that comply with the protocol and possibly an underlying "hazmat" library that contains a set of cryptographic algorithms.

You can find the Fernet specification here.

Libraries are available for the following programming languages:

Unofficially the following libraries claim conformance:

126 questions
0
votes
0 answers

How can I encrypt a file in React to be decrypted in Python using Fernet?

How would I encrypt my file in the client side with React to be decrypted in the server side with Python fernet. Wouldn't my file in the client side need to be encrypted by fernet as well. is it possible? Ive tried Fernetjs but it came up with a…
0
votes
0 answers

Getting error [password authentication failed for user] while encrypt DB credential in Django

Hi Everyone i am working on django framework my credential store in config.ini file but when i encrypt my db password and run server getting 500 error in log showing password authentication failed for user this will happen when i encrypt db password…
0
votes
0 answers

Fernet encryption/decryption adds white lines in Windows

I wrote a simple python script to encrypt (and then decrypt) a configuration file, using cryptography.fernet library. They work as expected on Linux systems, otherwise on Windows systems every time I decrypt the file it adds a newline in between…
0
votes
0 answers

PostGreSQL Encrypted Column sorting problem while searching in FastAPI

have Encrypted column in DB via Model like: from sqlalchemy_utils import StringEncryptedType first_name = sa.Column( StringEncryptedType(sa.Unicode, settings.encryption_key), nullable=True ) while try to search results its fetching…
kah
  • 71
  • 9
0
votes
0 answers

Str vs Integer when encoding (encrypting) and decoding(decrypting)

Thanks for pointing out the mistake @Topaco. Now it works like a charm. Question: If, within one table, I have more than one column which need to be encrypted, ['Salary', 'SocialNumber'] of type integer and string respectively, like: data =…
Susy84
  • 104
  • 6
0
votes
1 answer

Python 'bytes' object has no attribute 'decrypt'

I'm trying some encryption examples. and i keep get dec_msg = dec_key.decrypt(enc_msg) AttributeError: 'bytes' object has no attribute 'decrypt' this error. from cryptography.fernet import Fernet from cryptography.hazmat.backends import…
Dino_coder
  • 23
  • 5
0
votes
0 answers

Why won't my program create the file for a password with encrypted contents?

I am making a password manager program (as chatGPT suggested) what its supposed to do when you first start is to make the file containing the "Master Password" encrypted, but when I go test the program and enter the new master password, it doesn't…
0
votes
1 answer

cryptography.fernet.InvalidToken error when decrypting file

I'm playing with encryption and have come across this cryptography.fernet.InvalidToken error, which obviously means that the tokens don't match. The encrypter works fine, but the error is raised when running the decrypter. I can't figure out what's…
CUI
  • 51
  • 5
0
votes
1 answer

How to generate RSA private key using Fernet

This should be simple (famous last words) In the terminal, i can run this command: winpty openssl genrsa -des3 -out my_rsa_key_pair 2048 How can I do the exact same thing using pyca/cryptography ?
Dallas Caley
  • 5,367
  • 6
  • 40
  • 69
0
votes
0 answers

fernet.Token.fromBytes() fails with DateTimeException

I wrote a small python script a while ago, which uses the python cryptography module to encrypt some data using fernet. To do this, it reads the data from a file as bytes, runs the Fernet(key).encrypt(data) method, which returns a byte-object which…
ductTapeIsMagic
  • 113
  • 1
  • 8
0
votes
1 answer

Python, fernet decrypt turn my file read only

I'm with a personal proyect using python and sqlite3, the case is that i use fernet to encrypt the db file, but at decrypt the db it turn in a read only db and give me error at try do an INSERT. sqlite3.OperationalError: attempt to write a readonly…
Inoku
  • 39
  • 1
  • 5
0
votes
0 answers

Why do i keep getting invalid token when i've validated that the tokens are the exact same? Cryptography Fernet : Invalid Token

So the message is supposed to be decrypted here : def recv_message(self): while True: try: data = self.socket.recv(1024) # converting values from raw string into dictionary with json …
0
votes
0 answers

How to encrypt decrypted text by django-fernet-fields?

I am using django-fernet-fields, and documentation says By default, django-fernet-fields uses your SECRET_KEY setting as the encryption key. my SECRET_KEY in django is the one created by django let say it is "XXXX". my dectypted text is…
Elvin Jafarov
  • 1,341
  • 11
  • 25
0
votes
1 answer

File decryption in python with Fernet

When I try to decrypt text file it get me error 'bytes' object has no attribute 'decrypt'. Here's a code: k = open('C:/Documents/key.key', 'rb') key = k.read() k.close() f = open('C:/Documents/encrypted.txt', 'rb') enc =…
0
votes
0 answers

Decrypting a file with Fernet in Python is returning an empty string

I was testing creating a function to decrypt files within a directory using cryptography.fernet, but all I'm getting back is an empty string. I have looked elsewhere but could not find an answer. My current file is as such: import os from…
1 2 3
8 9