Projects In Development
In this example, we first encrypt the file using SHA-256, which is a widely-used hash function for data encryption. Then, we use IBM's Qiskit library and its Qiskrypt module to perform quantum state tomography on the file and extract its density matrix. The density matrix is saved to a file as the encrypted file. Note that this code is just a basic example.
01
SHA256 - Quantum File Encryption
Sample Code below written in Python:
import hashlib
from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister
from qiskit.extensions import Initialize
from qiskit.ignis.verification.tomography import state_tomography_circuits, StateTomographyFitter
import numpy as np
def sha256_encrypt(file_path):
with open(file_path, 'rb') as file:
sha256 = hashlib.sha256()
while True:
data = file.read(1024)
if not data:
break
sha256.update(data)
encrypted_file_path = file_path + '.sha256'
with open(encrypted_file_path, 'wb') as file:
file.write(sha256.hexdigest().encode('utf-8'))
return encrypted_file_path
def qiskrypt_encrypt(file_path):
# load the file into a numpy array
with open(file_path, 'rb') as file:
file_bytes = file.read()
np_array = np.array([int(byte) for byte in file_bytes], dtype=np.uint8)
# initialize the qubits to the desired state
qubits = QuantumRegister(len(np_array))
classical_bits = ClassicalRegister(len(np_array))
qc = QuantumCircuit(qubits, classical_bits)
initial_state = Initialize(np_array)
initial_state.label = 'initial_state'
qc.append(initial_state, range(len(np_array)))
# perform state tomography to extract the density matrix
tomography_circuits = state_tomography_circuits(qc, qubits)
fitter = StateTomographyFitter(tomography_circuits, backend)
result = fitter.fit(job.result())
density_matrix = result.density_matrix
# write the density matrix to a file
encrypted_file_path = file_path + '.qiskrypt'
with open(encrypted_file_path, 'wb') as file:
np.save(file, density_matrix)
return encrypted_file_path
# encrypt a file using SHA-256 and Qiskit's Qiskrypt
file_path = 'example.txt'
encrypted_file_path = sha256_encrypt(file_path)
encrypted_file_path = qiskrypt_encrypt(encrypted_file_path)
02
AI Powered
Price & Trend Predictor
Sample Code below:
​
Compatible with Tradingview.com
​
// This script uses a simple linear regression model to predict future prices
// Define variables
variables:
length(20), // number of bars to consider for the regression model
smooth(0.5), // smoothing factor for the regression line
up_color(color=green), // color for the regression line when trend is up
down_color(color=red), // color for the regression line when trend is down
threshold(0.05) // threshold for buy and sell signals
// Calculate the linear regression line
study("Linear Regression Model")
reg = linreg(close, length)
// Calculate the prediction for the next bar
prediction = reg * (1 + smooth)
// Plot the prediction
plot(prediction, title="Prediction", color=trend_up ? up_color : down_color, linewidth=3)
// Define a trend_up variable based on the slope of the regression line
trend_up = slope(reg) > 0
// Calculate the difference between the prediction and the close price
diff = prediction - close
// Buy signal
buy = crossover(diff, threshold)
// Sell signal
sell = crossunder(diff, -threshold)
// Plot the buy and sell signals
plotshape(buy, location=location.bottom, shape=shape.arrowup, color=up_color, size=size.small)
plotshape(sell, location=location.bottom, shape=shape.arrowdown, color=down_color, size=size.small)
This script uses a linear regression model to predict the next bar's close price based on the previous length bars. The smooth factor is used to smooth the regression line. The trend of the regression line is determined based on the slope of the line, and the color of the line changes accordingly. In this script, we have added a threshold variable to define the difference between the prediction and the close price that triggers a buy or sell signal. The buy signal is triggered when the difference crosses above the threshold, and the sell signal is triggered when the difference crosses below the negative threshold. The buy and sell signals are plotted as arrows on the chart.
03
Price Tracking API Correction on Nomics.com
Sample API below:
import requests
# Set the API endpoint and parameters
endpoint = "https://api.nomics.com/v1/assets/qai-quantumai"
parameters = {
"key": "YOUR_API_KEY",
"interval": "1d"
}
# Make the API request
response = requests.get(endpoint, params=parameters)
# Get the data from the response
data = response.json()
# Extract the relevant data
usd_value = data["price"]["usd"]
circulating_supply = data["circulating_supply"]
max_supply = data["max_supply"]
market_cap = data["market_cap"]["usd"]
# Print the data
print("USD Value: $" + usd_value)
print("Circulating Supply: " + circulating_supply)
print("Max Supply: " + max_supply)
print("Market Capitalization: $" + market_cap)
04
AI Chatbot
Sample Code below written in php:
<!DOCTYPE html>
<html>
<head>
<title>AI Chat Box</title>
<style>
#chatbox {
width: 400px;
height: 400px;
border: 1px solid black;
position: fixed;
bottom: 20px;
right: 20px;
padding: 20px;
overflow-y: scroll;
}
#input-form {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
#user-input {
width: 75%;
}
</style>
</head>
<body>
<div id="chatbox">
<div id="chat-output"></div>
<form id="input-form">
<input type="text" id="user-input" placeholder="Ask me anything...">
<button type="button" id="submit-btn">Submit</button>
</form>
</div>
<script>
const submitBtn = document.querySelector("#submit-btn");
const userInput = document.querySelector("#user-input");
const chatOutput = document.querySelector("#chat-output");
submitBtn.addEventListener("click", function(event) {
event.preventDefault();
// Get user input
const input = userInput.value;
// Call your AI chat bot function and get response
const response = callChatBot(input);
// Display the response in the chat output
chatOutput.innerHTML += "<p>Bot: " + response + "</p>";
// Clear the user input
userInput.value = "";
});
</script>
</body>
</html>