Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions HeadlineHackathon/Dreamf1re_hack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Choice Texts
This is a web app, designed with PyWebIO, which aims to make text files permanent on the Algorand Blockchain.

## Usage
1. Download this entire folder.
2. Install required packages using ```pip install -r requirements.txt```.
3. Edit Environment Variables -> add variable name "test_mnemonic" with variable value which is your test mnemonic. <br> Make sure to fund this account with TestNet ALGOs.
5. Run deploy.py through ```python deploy.py```.

Running deploy.py will start a new tab in the user's default
web browser. All functionalities therein are intact and the user
can now start making text files permanent on the Algorand blockchain.

## Notes
Only use text files that are allowed to be accessed publicly. Never use this web app with <br/>
text files containing private information as they will be made permanent in the Algorand blockchain <br/>
which is a ```public``` blockchain.
31 changes: 31 additions & 0 deletions HeadlineHackathon/Dreamf1re_hack/bridge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from upload import upload, get_file_id
from download import download
from util import TEST_SENDER_ADDRESS, TEST_SENDER_PRIVATE_KEY, init_post_client


def upload_pdf(filename: str):
# Upload sample, returns a Transaction ID
# needed to retrieve the file from the blockchain
print("Procedure: Upload file to blockchain.")
txnids = upload(
filename=filename,
sender_address=TEST_SENDER_ADDRESS,
sender_private_key=TEST_SENDER_PRIVATE_KEY
)
fid = get_file_id(
transaction_ids=txnids,
receiver_address=TEST_SENDER_ADDRESS,
sender_address=TEST_SENDER_ADDRESS,
sender_private_key=TEST_SENDER_PRIVATE_KEY,
post_client=init_post_client(),
filename=filename
)
print(f"File ID: {fid}")
return fid


def download_pdf(file_id: str):
# Download sample, saves to current directory
print("Procedure: Download file from blockchain.")
filedld, filedldname = download(file_id=file_id)
return filedld, filedldname
40 changes: 40 additions & 0 deletions HeadlineHackathon/Dreamf1re_hack/checking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import hashlib


# Vital function to check if
# the uploaded file and downloaded
# file are exactly the same. This
# is achieved through checking if
# the hash of the uploaded data is
# equal to the hash of the
# downloaded data
def check_circular(original: str, stitched: str):
"""
Check if hashes of Original File and Downloaded File are
the same. This is to check if the uploaded file is complete
and is the same with the original file that has been uploaded.

:param original: The original file.
:param stitched: The downloaded file.
:return: Returns True if original and downloaded hashes are the same.
"""
print(f'\nChecking circularity...')
stitched_hash = hashlib.md5(stitched.encode()).hexdigest()
original_hash = hashlib.md5(original.encode()).hexdigest()
if stitched_hash == original_hash:
print('Achieved circularity.')
return True
else:
print(f'Length of original: {len(original)} Hash: {original_hash}')
print(f'Length of stitched: {len(stitched)} Hash: {stitched_hash}')
print(f'Circularity not achieved. Trying again.')


# Check if the expected Transaction ID
# location in the note is all in uppercase
def check_if_connection_exists(note: str):
targ = note[(len(note)-1)-51:len(note)]
if targ.isupper():
return True
else:
return False
Binary file added HeadlineHackathon/Dreamf1re_hack/choice_logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions HeadlineHackathon/Dreamf1re_hack/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALGONODE_NODE_ADDRESS = "http://testnet-api.algonode.network"
ALGONODE_INDX_ADDRESS = "http://testnet-idx.algonode.network"
ALGOEXPL_NODE_ADDRESS = "https://node.testnet.algoexplorerapi.io"
ALGOEXPL_INDX_ADDRESS = "https://algoindexer.testnet.algoexplorerapi.io"
Loading