def regmeinplease(request): if request.method == 'POST': datareponse = {} email = request.POST.get('email') username = request.POST.get('username') password = request.POST.get('password') private_key = utils.sha3(os.urandom(4096)) raw_address = utils.privtoaddr(private_key) addressif = address.to_normalized_address(raw_address) keyether = utils.encode_hex(private_key) sk = SigningKey.from_string(bytes.fromhex(keyether), curve=SECP256k1) public_key = sk.get_verifying_key() #public_key pkey = public_key.to_string().hex().strip() randomstring = id_generator(10, "ABCDEFGJKLMNOPRSTUVYZ1234567890") mailverify = id_generator(10, "ABCDEFGJKLMNOPRSTUVYZ1234567890") gauth = pyotp.random_base32() addnewuser = User(email=email, username=username, password=password, ethereumaddress=addressif, privatekey=keyether, publickey=pkey, moneycode=randomstring, random_base32=gauth, mailverifycode=mailverify, twofactorenabled=False) addnewuser.save() datareponse["response"] = "ok" return HttpResponse(json.dumps(datareponse), content_type="application/json") else: datareponse["info"] = "Only Post RQ" datareponse["response"] = "none" return HttpResponse(json.dumps(datareponse), content_type="application/json")
def generate(request): private_key = utils.sha3(os.urandom(4096)) raw_address = utils.privtoaddr(private_key) addressif = address.to_normalized_address(raw_address) keyether = utils.encode_hex(private_key) sk = SigningKey.from_string(bytes.fromhex(keyether), curve=SECP256k1) public_key = sk.get_verifying_key() #public_key pkey = public_key.to_string().hex().strip() data = b'https://darchnetwork.com/' encryptedval = encrypt(pkey, data) print("encryptedval", utils.encode_hex(encryptedval)) decryptedvalue = decrypt(keyether, encryptedval) print("decrypted value is here", decryptedvalue) #public_key = public_key.to_string().hex() return render(request, "homomorphic/skeleton.html", locals())
def test_to_normalized_address(value, expected): assert to_normalized_address(value) == expected