My code looks like:
from django.shortcuts import render, redirect
from django.contrib.auth.models import User, auth
from django.contrib import messages
from .models import Details
from bitcoin import *
import random
import bs4
import requests
def login(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = auth.authenticate(username=username, password=password)
if user is not None:
auth.login(request, user)
return redirect('/')
else:
messages.info(request, 'Invalid Credentials')
return redirect('login')
else:
return render(request, 'login.htm')
def register(request):
detail = Details()
bits = random.getrandbits(256)
bits_hex = hex(bits)
private_key = bits_hex[2:]
print(private_key)
# private_key = random_key()
public_key = privtopub(private_key)
address = pubtoaddr(public_key)
detail.private_key = private_key
detail.public_key = public_key
detail.address = address
But I get the error: name 'privtopub' is not defined
Aucun commentaire:
Enregistrer un commentaire