91 lines
2.9 KiB
Python
91 lines
2.9 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from AnyankaKeys import AnyankaKeys
|
|
|
|
class Tests:
|
|
|
|
@staticmethod
|
|
def change_base() -> None:
|
|
|
|
for prueba in [
|
|
[1, 2, 3],
|
|
[2, 5, 5],
|
|
[3, 2],
|
|
[0]
|
|
]:
|
|
|
|
ncripted:list[int] = []
|
|
decripted:list[int] = []
|
|
|
|
def ncript(value:int) -> None:
|
|
ncripted.insert(0, value)
|
|
# ncripted.append(value)
|
|
|
|
def decript(value:int) -> None:
|
|
decripted.insert(0, value)
|
|
# decripted.append(value)
|
|
|
|
AnyankaKeys.change_base(prueba, 2, 16, None, ncript)
|
|
AnyankaKeys.change_base(ncripted, 16, 2, None, decript)
|
|
|
|
print(["O", prueba])
|
|
# print(["A", AnyankaKeys.to_base(prueba, 16, 10, lambda value:print(["C", value]))])
|
|
# print(["B", list(AnyankaKeys.to_base_old(prueba, 16, 10))])
|
|
print(["A", ncripted])
|
|
print(["B", decripted])
|
|
|
|
@staticmethod
|
|
def basic_encript() -> None:
|
|
|
|
anyanka:AnyankaKeys = AnyankaKeys({
|
|
"password": "MiContraseñaSecreta123!@#",
|
|
})
|
|
|
|
for prueba in [
|
|
"Hola Mundo",
|
|
"Hola Mundo",
|
|
"Iola Mundo",
|
|
"Hola Mundo1",
|
|
"AnyankaKeys",
|
|
"1234567890",
|
|
"!@#$%^&*()_+-=[]{}|;':\",./<>?"
|
|
]:
|
|
encrypted:str = anyanka.encrypt(prueba)
|
|
decrypted:str = anyanka.decrypt(encrypted)
|
|
|
|
print(["O", prueba])
|
|
print(["A", encrypted])
|
|
print(["B", decrypted])
|
|
|
|
@staticmethod
|
|
def get_hexadecimal() -> None:
|
|
print(["0x" + hex(value)[2:].upper() for value in (
|
|
# -- Grupo 1: Constantes de Dispersión Máxima (Golden/Silver Ratios) --
|
|
2654435761, # 0x9E3779B1 (Knuth's Golden Ratio Prime)
|
|
1865882353, # Cerca de 2^32 / sqrt(5)
|
|
3339476533, # Alta entropía
|
|
|
|
# -- Grupo 2: Primos "Sucios" (Mezcla perfecta de 0s y 1s) --
|
|
# Estos números parecen ruido estático en binario.
|
|
32416190071 & 0xFFFFFFFF, # (Nota: Ajustado a 32 bits si copias de 64) -> Usamos estos directos:
|
|
2246822519, # Primo cercano a Murmur constant
|
|
3266489917,
|
|
668265263,
|
|
374761393,
|
|
|
|
# -- Grupo 3: Primos Grandes (Cercanos al límite de 32-bit signed) --
|
|
2147483647, # 2^31 - 1 (Mersenne Prime - Clásico)
|
|
2147483629, # Un poco menos que el máximo
|
|
2147483587,
|
|
|
|
# -- Grupo 4: Primos de "Grano Fino" (Para variedad en rangos medios) --
|
|
160481183,
|
|
486187739,
|
|
999999937, # El primo más grande menor de mil millones
|
|
1000000007
|
|
)])
|
|
|
|
# Tests.change_base()
|
|
Tests.basic_encript()
|
|
# Tests.get_hexadecimal() |