Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pruebas y testeo solidity #411

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f5ac501
add
Chicook Dec 23, 2024
1051a9e
add
Chicook Dec 23, 2024
1906c82
add
Chicook Dec 23, 2024
8f75be4
Merge branch 'Chicook:WoldVirtual.0.0.1' into Desarrollo-y-pruebas-ge…
Chicook Dec 23, 2024
07b6bd5
Update BK_ST2.py
Chicook Dec 23, 2024
7dbde86
Create BK_ST3.py
Chicook Dec 23, 2024
3ac4d03
Update BK_ST3.py
Chicook Dec 23, 2024
24df021
Create BK_ST4
Chicook Dec 23, 2024
802c36f
Rename BK_ST4 to BK_ST4.py
Chicook Dec 23, 2024
81baa26
Update BK_ST4.py
Chicook Dec 23, 2024
56756a5
Update BK_ST2.py
Chicook Dec 23, 2024
32f697b
Update BK_ST1.py
Chicook Dec 23, 2024
d11735f
Update BK_ST1.py
Chicook Dec 23, 2024
df0422d
Update BK_ST1.py
Chicook Dec 23, 2024
9db9561
Update BK_ST1.py
Chicook Dec 23, 2024
79d3d99
Update BK_ST1.py
Chicook Dec 23, 2024
d5f11a3
Update BK_ST1.py
Chicook Dec 23, 2024
659b28d
Update BK_ST1.py
Chicook Dec 23, 2024
af73b3e
Update BK_ST1.py
Chicook Dec 23, 2024
910644d
Update BK_ST1.py
Chicook Dec 23, 2024
645c4ab
Update BK_ST1.py
Chicook Dec 23, 2024
840c62d
Update BK_ST1.py
Chicook Dec 23, 2024
91ea46b
Desarrollo y pruebas generales (#259)
Chicook Dec 23, 2024
de8f11a
Update BK_ST1.py
Chicook Dec 23, 2024
73e09a4
Update BK_ST1.py
Chicook Dec 23, 2024
4a63b1d
Create BK_Usuarios.py
Chicook Dec 23, 2024
4a47c52
add
Chicook Dec 23, 2024
b6486ee
add
Chicook Dec 23, 2024
1c995d1
Update BK_ST2.py
Chicook Dec 23, 2024
1a9f1ee
Update BK_ST3.py
Chicook Dec 23, 2024
7df1227
Update BK_ST3.py
Chicook Dec 23, 2024
1ee515d
Update BK_ST4.py
Chicook Dec 23, 2024
f882ca2
add
Chicook Dec 23, 2024
6d99fd6
Pruebas y cambios (#260)
Chicook Dec 23, 2024
e5ea020
Update BK_ST1.py
Chicook Dec 23, 2024
4e6086e
Update BK_Usuarios.py
Chicook Dec 23, 2024
0a3ac6c
Update BK_ST2.py
Chicook Dec 23, 2024
3ea8095
Update BK_ST2.py
Chicook Dec 23, 2024
b8a6c37
Update BK_ST3.py
Chicook Dec 23, 2024
46c6641
Update BK_ST4.py
Chicook Dec 23, 2024
85ec0b4
Create __init__.py
Chicook Dec 23, 2024
0353da5
Update __init__.py
Chicook Dec 23, 2024
c59e4cf
add
Chicook Dec 23, 2024
36d11bf
add
Chicook Dec 23, 2024
be71630
add
Chicook Dec 23, 2024
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
30 changes: 30 additions & 0 deletions public/STM/BK_ST1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# principal.py

from STMDL.BK_ST2 import registrar_usuario
from STMDL.BK_ST3 import verificar_credenciales
from STMDL.BK_ST4 import manejar_accion
from STMDL.BK_Usuarios import inicializar_usuarios


if __name__ == '__main__':
# Inicializar sistema de usuarios
inicializar_usuarios()

# Datos del usuario
username = 'usuario1'
password = 'contraseña_segura'

# Registrar usuario
if registrar_usuario(username, password):
print(f'Usuario "{username}" registrado con éxito.')
else:
print(f'Error: El usuario "{username}" ya existe.')

# Verificar credenciales
if verificar_credenciales(username, password):
print(f'Credenciales verificadas con éxito para "{username}".')
else:
print(f'Error: Fallo al verificar credenciales para "{username}".')

# Manejar acción
manejar_accion(username, "explorar")
13 changes: 13 additions & 0 deletions public/STM/STMDL/BK_ST2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import hashlib
from STMDL.BK_Usuarios import usuarios

def registrar_usuario(username, password):
"""
Registra un nuevo usuario con su contraseña.
Devuelve True si el usuario fue registrado, False si ya existe.
"""
if username in usuarios:
return False
hashed_password = hashlib.sha256(password.encode()).hexdigest()
usuarios[username] = hashed_password
return True
15 changes: 15 additions & 0 deletions public/STM/STMDL/BK_ST3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# modulos/BK_ST3.py

import hashlib
from STMDL.BK_Usuarios import usuarios

def verificar_credenciales(username, password):
"""
Verifica si las credenciales del usuario son correctas.
Devuelve True si coinciden, False en caso contrario.
"""
if username not in usuarios:
print(f'Error: El usuario "{username}" no existe.')
return False
hashed_password = hashlib.sha256(password.encode()).hexdigest()
return usuarios[username] == hashed_password
12 changes: 12 additions & 0 deletions public/STM/STMDL/BK_ST4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# modulos/BK_ST4.py

def manejar_accion(usuario, accion):
"""
Realiza una acción específica para el usuario.
"""
if accion == "explorar":
print(f"Bienvenido/a {usuario} al entorno de exploración.")
elif accion == "intercambiar":
print(f"Realizando intercambio para {usuario}.")
else:
print(f"Error: Acción '{accion}' no reconocida.")
6 changes: 6 additions & 0 deletions public/STM/STMDL/BK_Usuarios.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
usuarios = {}

def inicializar_usuarios():
"""Inicializa la estructura global de usuarios."""
global usuarios
usuarios = {}
43 changes: 43 additions & 0 deletions public/STM/STMDL/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import hashlib
import time

# def compress_files(files, output_filename):

# Comprime una lista de archivos en un archivo tar.gz.

class Block:
def __init__(self, index, previous_hash, timestamp, data, hash):
self.index = index
self.previous_hash = previous_hash
self.timestamp = timestamp
self.data = data
self.hash = hash

def calculate_hash(index, previous_hash, timestamp, data):
return hashlib.sha256(f"{index}{previous_hash}{timestamp}{data}".encode()).hexdigest()

def create_genesis_block():
return Block(0, "0", int(time.time()), "Genesis Block", calculate_hash(0, "0", int(time.time()), "Genesis Block"))

def create_new_block(previous_block, data):
index = previous_block.index + 1
timestamp = int(time.time())
hash = calculate_hash(index, previous_block.hash, timestamp, data)
return Block(index, previous_block.hash, timestamp, data, hash)

# Crear la blockchain y añadir el bloque génesis
blockchain = [create_genesis_block()]

def add_block(data):
previous_block = blockchain[-1]
new_block = create_new_block(previous_block, data)
blockchain.append(new_block)

# Ejemplo de uso
if __name__ == '__main__':
data = 'Datos del paquete de módulos'
data_hash = hashlib.sha256(data.encode()).hexdigest()
add_block(data_hash)

for block in blockchain:
print(f"Bloque {block.index} - Hash: {block.hash}")