#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
from flask import Flask
import binascii
import rsa.randnum
import cryptography
from Crypto.Cipher import Salsa20
from cryptography.fernet import Fernet, MultiFernet
import base64
import qrcode
import image
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.backends import default_backend
from authlib.specs.rfc7519 import jwt
from cryptography.hazmat.primitives.serialization import load_pem_public_key
from cryptography import x509
from cryptography.hazmat.primitives.hashes import HashContext
import datetime
private_key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048,
backend=default_backend()
)
pem = private_key.private_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.PKCS8,
encryption_algorithm=serialization.BestAvailableEncryption(b'mypassword')
)
pem.splitlines()[0]
print(pem)
class Key_Private():
def __init__(self, private_key):
self.__private_key = private_key
def private_key_funct(self):
return self.__private_key
def __str__(self):
return b'Your private key: {0}'.format(self.__private_key).encode()
new_private_key = Key_Private(private_key) #Key_Private(private_key)
print(new_private_key)
Ошибка AttributeError: 'bytes' object has no attribute 'format' как решить?