from cryptography.hazmat.backends import default_backend
from cryptography.hazmat import backends
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives import hashes
import base64
private_key = serialization.load_der_private_key(pub_key_bytes, password=None, backend=default_backend())
signature = private_key.sign(data=serialized_data.encode('utf-8'),algorithm=hashes.SHA256(), padding=padding.PKCS1v15())
sign = base64.b64encode(signature).decode('utf-8')
import vk, requests, os
session = vk.Session(access_token=access_token)
api = vk.API(session, v='5.8')
profile = api.users.get(user_id=user_id, fields=["photo_100",'sex','nickname', 'bdate'])[0]
#Записываем на диск фото с vk
data = requests.get(profile['photo_100'])
filename = os.path.join(os.getcwd()+'/static/usersdata/photos', user_id+'.jpg')
try:
f=open(filename,'wb')
f.write(data.content)
f.close()
except FileNotFoundError:
return {'errorfilewrite': True}