kha256 package

KHA-256 (Keçeci Hash Algorithm) - A cryptographic hash algorithm.

KEÇECİ HASH ALGORITHM (KEÇECİ HASH ALGORİTMASI), KHA-256

Security-maximized version with performance trade-offs for maximum security. Performanstan fedakarlık edilerek güvenlik maksimize edilmiş versiyondur. ========================================================

A next-generation cryptographic hash algorithm based on Keçeci Numbers and mathematical constants.

author:

Mehmet Keçeci

license:

AGPL-3.0-or-later

copyright:

Copyright 2025-2026 Mehmet Keçeci

class kha256.KHA256[source]

Bases: object

KHA-256 - TAMAMEN ORİJİNAL HASH FONKSİYONU

✓ Hiçbir standart hash’ten kod alınmamıştır ✓ Tüm sabitler matematiksel irrasyonellerden üretilmiştir ✓ Perfect avalanche hedefi: 128.00/128.00 ✓ HMAC desteği ==========================================

hash(data, salt=None, *, deterministic=False, memory_hard=False, memory_mb=1)[source]
Parameters:
Return type:

str

hmac(key, message)[source]

KHA-256 HMAC (Hash-based Message Authentication Code)

Parameters:
Return type:

str

verify(data, hash_str, salt, **kwargs)[source]

Hash doğrulama

Parameters:
Return type:

bool

property version: str
property metrics: Dict[str, Any]
class kha256.KHA256b[source]

Bases: object

property version: str

KHA-256 version

property certificate: str

Perfect Avalanche certificate number

property metrics: Dict[str, Any]

Performance metrics

property avalanche_score: float

128.00

Type:

Perfect avalanche score

hash(data, salt=None, *, deterministic=False, memory_hard=False, memory_mb=1)[source]

Compute KHA-256 hash - PERFECT AVALANCHE

Parameters:
  • data (str | bytes) – Input data to hash

  • salt (bytes | None) – Salt value (auto-generated if None)

  • deterministic (bool) – Use deterministic mode (requires salt)

  • memory_hard (bool) – Use memory-hard mode for passwords

  • memory_mb (int) – Memory in MB for memory-hard mode

Returns:

64-character hex hash (256-bit) with PERFECT AVALANCHE

Return type:

str

verify(data, hash_str, salt, **kwargs)[source]

Constant-time hash verification

Parameters:
Return type:

bool

hmac(key, message)[source]

KHA-256 HMAC - Perfect avalanche

Parameters:
Return type:

str

self_test()[source]

Run self-test to verify Perfect Avalanche

Return type:

bool

class kha256.FortifiedKhaHash256(config=None, *, deterministic=True)[source]

Bases: object

Fortified KHA Hash (KHA-256) - Ultra Secure

Parameters:
KEY_SIZE = 32
NONCE_SIZE = 12
hash(**kwargs)[source]
get_cache_stats()[source]

Cache istatistiklerini getir

Return type:

Dict[str, Any]

clear_cache()[source]

Cache’i temizle

Return type:

None

property deterministic

Deterministic özelliği için getter

test_avalanche_effect(samples=1000)[source]

Statistical Avalanche Effect Test - OPTİMİZE EDİLMİŞ

Parameters:

samples (int)

Return type:

Dict[str, Any]

test_collision_resistance(samples=10000)[source]
Parameters:

samples (int)

Return type:

Dict[str, Any]

test_uniformity(samples=10000)[source]

Statistical uniformity test for hash output.

Parameters:

samples (int)

Return type:

Dict[str, Any]

get_stats()[source]

İstatistikleri getir

Return type:

Dict[str, Any]

get_security_report()[source]

Güvenlik raporu

Return type:

Dict[str, Any]

class kha256.OptimizedKhaHash256(config=None, *, deterministic=True, turbo_mode=True)[source]

Bases: FortifiedKhaHash256

SIMPLE & FAST KHA-256 implementation. No micro-optimizations, just the essentials for speed.

Parameters:
__init__(config=None, *, deterministic=True, turbo_mode=True)[source]

Initialize the optimized hasher with minimal overhead.

Parameters:
metrics: Dict[str, Any]
hash(data, salt=None)[source]

Compute optimized hash of data - MINIMAL OVERHEAD

Parameters:
Return type:

str

get_cache_stats()[source]

Get cache statistics

Return type:

Dict[str, Any]

clear_cache()[source]

Clear all caches

Return type:

None

get_metrics()[source]

Get performance metrics

Return type:

Dict[str, Any]

enable_turbo_mode(enable=True)[source]

Enable or disable turbo mode

Parameters:

enable (bool)

Return type:

None

class kha256.SecureKhaHash256[source]

Bases: object

hash(data, salt)[source]
Parameters:
Return type:

bytes

verify_avalanche(n=10000)[source]
class kha256.HybridKhaHash256(config=None, *, deterministic=True, turbo_mode=True, hybrid_mode=True)[source]

Bases: FortifiedKhaHash256

HYBRID KHA-256 implementation. Uses BLAKE2s for small data, KHA for large data.

Parameters:
SMALL_DATA_THRESHOLD = 1024
MEDIUM_DATA_THRESHOLD = 8192
__init__(config=None, *, deterministic=True, turbo_mode=True, hybrid_mode=True)[source]

Initialize the hybrid hasher.

Parameters:
  • config (OptimizedFortifiedConfig | FortifiedConfig | None) – Configuration object

  • deterministic (bool) – Whether to use deterministic behavior

  • turbo_mode (bool) – Enable extreme optimizations for speed

  • hybrid_mode (bool) – Enable hybrid mode (BLAKE2s for small, KHA for large)

metrics: Dict[str, Any]
hash(data, salt=None)[source]

Compute hybrid hash of data

Parameters:
Return type:

str

get_cache_stats()[source]

Get cache statistics

Return type:

Dict[str, Any]

clear_cache()[source]

Clear all caches

Return type:

None

get_metrics()[source]

Get performance metrics

Return type:

Dict[str, Any]

enable_hybrid_mode(enable=True)[source]

Enable or disable hybrid mode

Parameters:

enable (bool)

Return type:

None

class kha256.SimpleKhaHasher(salt=None)[source]

Bases: object

Basit KHA hasher - Demo ve test amaçlı, DETERMINISTIK!

Parameters:

salt (bytes)

DEFAULT_SALT = b'KHA_DEFAULT_SALT_32BYTES!!'
__init__(salt=None)[source]
Parameters:

salt (bytes) – Özel salt (opsiyonel). Verilmezse DEFAULT_SALT kullanılır.

hash(data, salt=None)[source]

String input → KHA hash (deterministik)

Parameters:
Return type:

str

get_security_report()[source]
Return type:

Dict[str, Any]

class kha256.Shake256Hasher(output_length=32)[source]

Bases: object

SHAKE256 hash sınıfı - ek özelliklerle from Crypto.Hash import SHAKE256

__init__(output_length=32)[source]

SHAKE256 hasher başlatıcı

Parameters:

output_length – Varsayılan çıktı uzunluğu (bytes)

hash(data, output_length=None)[source]

Veriyi hash’ler

Parameters:
  • data – Hash’lenecek veri

  • output_length – Çıktı uzunluğu (None ise varsayılan kullanılır)

Returns:

Hash değeri

Return type:

bytes

hash_hex(data, output_length=None)[source]

Hash’i hex string olarak döndür

hash_int(data, output_length=None)[source]

Hash’i integer olarak döndür

file_hash(filepath, output_length=32)[source]

Dosyanın hash’ini hesaplar

class kha256.TrueMemoryHardHasher(memory_cost_kb, time_cost, parallelism=1)[source]

Bases: object

NIST SP 800-193 uyumlu gerçek memory-hard hasher (Balloon hashing tabanlı).

🔒 KATI KURAL: salt ZORUNLU! - Deterministic hash için salt OLMALIDIR! - salt=None KABUL EDİLMEZ!

Parameters:
  • memory_cost_kb (int)

  • time_cost (int)

  • parallelism (int)

hash(password, salt)[source]

🔒 DETERMINISTIC memory-hard hash!

Parameters:
  • password (str | bytes) – Hash’lenecek veri (str veya bytes)

  • salt (bytes) – 32-byte tuz (ZORUNLU! None olamaz!)

Returns:

64 karakter hex string

Raises:
Return type:

str

verify(password, stored_hash, salt)[source]

Hash doğrulama - salt ZORUNLU!

Parameters:
Return type:

bool

class kha256.CoreEngine[source]

Bases: object

SHA-512 core - PERFECT AVALANCHE 128.00/128.00

classmethod hash(data, salt)[source]

256-bit hash - PERFECT AVALANCHE

Parameters:
Return type:

bytes

class kha256.CoreHash[source]

Bases: object

KHA-CORE - Ana hash çekirdeği

classmethod hash(data, salt)[source]
Parameters:
Return type:

bytes

class kha256.DeterministicEngine[source]

Bases: object

BLAKE2b deterministic hash - PERFECT

classmethod hash(data)[source]

32-byte deterministic hash

Parameters:

data (bytes)

Return type:

bytes

class kha256.DeterministicHash[source]

Bases: object

KHA-DET - Deterministic hash

classmethod hash(data)[source]
Parameters:

data (bytes)

Return type:

bytes

class kha256.MemoryHardEngine(memory_mb=1, iterations=3)[source]

Bases: object

Memory-hard hash - PERFECT AVALANCHE

Parameters:
  • memory_mb (int)

  • iterations (int)

blocks
iterations
hash(data, salt)[source]

Memory-hard hash - PERFECT

Parameters:
Return type:

str

class kha256.MemoryHardHash(memory_mb=1, iterations=3)[source]

Bases: object

KHA-MH - Memory-hard hash

Parameters:
  • memory_mb (int)

  • iterations (int)

memory_blocks
iterations
hash(data, salt)[source]
Parameters:
Return type:

str

class kha256.FortifiedKhaCore(config)[source]

Bases: object

Fortified KHA Hash Core Engine

Parameters:

config (FortifiedConfig)

stats: Dict[str, int | float]
text_stats: Dict[str, str]
list_stats: Dict[str, list]
dict_stats: Dict[str, dict]
hash(data, salt)[source]

KHA-256 core hash fonksiyonu

Parameters:
Return type:

str

class kha256.PerformanceOptimizedKhaCore(config)[source]

Bases: FortifiedKhaCore

Performans optimize edilmiş KHA çekirdeği

Parameters:

config (FortifiedConfig)

class kha256.MockCore(deterministic=True)[source]

Bases: object

class MockConfig[source]

Bases: object

shuffle_layers = 4
deterministic = True
enable_quantum_mix = True
enable_diffusion_mix = True
salt_length = 16
class kha256.StreamingKHA256(salt=None)[source]

Bases: object

Büyük veriler için parçalı hash hesaplama - KESİN ÇÖZÜM

Kullanım:

hasher = StreamingKHA256(salt) hasher.update(chunk1) hasher.update(chunk2) hash_value = hasher.hexdigest()

Özellikler:
  • AYNI SALT ile tüm hash’lemeler yapılır

  • Son hash, tüm parçaların birleşiminin hash’ine EŞİTTİR

  • Büyük dosyalar için idealdir

Parameters:

salt (Optional[bytes])

update(chunk)[source]

Veri parçası ekle - KESİN ÇÖZÜM SADECE buffer modu - %100 çalışıyor!

Parameters:

chunk (bytes)

digest()[source]

Final hash (bytes)

Return type:

bytes

hexdigest()[source]

Final hash (hex string)

Return type:

str

reset()[source]

State’i sıfırla

class kha256.FortifiedConfig(output_bits=256, hash_bytes=32, iterations=4, rounds=6, components_per_hash=32, salt_length=32, shuffle_layers=5, diffusion_rounds=6, avalanche_boosts=4, use_enhanced_avalanche=True, enable_quantum_mix=True, enable_diffusion_mix=True, triple_compression=False, memory_hardening=True, enable_byte_distribution_optimization=True, byte_uniformity_rounds=4, time_varying_salt=True, context_sensitive_mixing=True, enable_side_channel_resistance=True, enable_constant_time_ops=True, enable_arithmetic_blinding=True, memory_cost=<property object>, memory_cost_kb=1024, time_cost=2, parallelism=1, _legacy_memory_cost=None, cache_enabled=True, cache_size=512, cache_ttl=None, cache_hmac_protected=True, cache_deterministic=True, parallel_processing=False, max_workers=1, enable_memory_hard_mode=False, double_hashing=False, enable_encryption_layer=True, encryption_rounds=3, enable_hamming_weight_balancing=False, target_hamming_weight=0.5, chi_square_optimization=True, enable_case_aware_mixing=False, case_sensitivity_boost=1.0, ascii_case_amplification=1.0, case_diffusion_factor=0.0)[source]

Bases: object

Performans-Güvenlik dengesi optimize edilmiş config Production-ready konfigürasyon: Güvenlik skorları %95+ korunurken performans %95+ hedeflenir. NIST SP 800-132/63B/90B uyumlu.

Parameters:
  • output_bits (int)

  • hash_bytes (int)

  • iterations (int)

  • rounds (int)

  • components_per_hash (int)

  • salt_length (int)

  • shuffle_layers (int)

  • diffusion_rounds (int)

  • avalanche_boosts (int)

  • use_enhanced_avalanche (bool)

  • enable_quantum_mix (bool)

  • enable_diffusion_mix (bool)

  • triple_compression (bool)

  • memory_hardening (bool)

  • enable_byte_distribution_optimization (bool)

  • byte_uniformity_rounds (int)

  • time_varying_salt (bool)

  • context_sensitive_mixing (bool)

  • enable_side_channel_resistance (bool)

  • enable_constant_time_ops (bool)

  • enable_arithmetic_blinding (bool)

  • memory_cost (int)

  • memory_cost_kb (int)

  • time_cost (int)

  • parallelism (int)

  • _legacy_memory_cost (int | None)

  • cache_enabled (bool)

  • cache_size (int)

  • cache_ttl (int | None)

  • cache_hmac_protected (bool)

  • cache_deterministic (bool)

  • parallel_processing (bool)

  • max_workers (int)

  • enable_memory_hard_mode (bool)

  • double_hashing (bool)

  • enable_encryption_layer (bool)

  • encryption_rounds (int)

  • enable_hamming_weight_balancing (bool)

  • target_hamming_weight (float)

  • chi_square_optimization (bool)

  • enable_case_aware_mixing (bool)

  • case_sensitivity_boost (float)

  • ascii_case_amplification (float)

  • case_diffusion_factor (float)

VERSION: ClassVar[str] = '0.2.9'
ALGORITHM: ClassVar[str] = 'KHA-256'
output_bits: int = 256
hash_bytes: int = 32
iterations: int = 4
rounds: int = 6
components_per_hash: int = 32
salt_length: int = 32
shuffle_layers: int = 5
diffusion_rounds: int = 6
avalanche_boosts: int = 4
use_enhanced_avalanche: bool = True
enable_quantum_mix: bool = True
enable_diffusion_mix: bool = True
triple_compression: bool = False
memory_hardening: bool = True
enable_byte_distribution_optimization: bool = True
byte_uniformity_rounds: int = 4
time_varying_salt: bool = True
context_sensitive_mixing: bool = True
enable_side_channel_resistance: bool = True
enable_constant_time_ops: bool = True
enable_arithmetic_blinding: bool = True

# PERFORMANS (bit kalitesi için fedakarlık) cache_enabled: bool = True # True → False (deterministik olmama) cache_size: int = 32 parallel_processing: bool = False # True → False (bit sırası önemli) max_workers: int = 1

# MEMORY HARDENING (bit pattern’leri kırmak için) memory_cost: int = 2**18 # 2**16 → 2**18 (256KB) time_cost: int = 6 # 3-4 → 6 parallelism: int = 1 # 2 → 1 (bit sırası tutarlılığı)

memory_cost_kb: int = 1024
time_cost: int = 2
parallelism: int = 1
property memory_cost

use memory_cost_kb instead

Type:

Deprecated

cache_enabled: bool = True
cache_size: int = 512
cache_ttl: int | None = None
cache_hmac_protected: bool = True
cache_deterministic: bool = True
parallel_processing: bool = False
max_workers: int = 1
enable_memory_hard_mode: bool = False
double_hashing: bool = False
enable_encryption_layer: bool = True
encryption_rounds: int = 3
enable_hamming_weight_balancing: bool = False
target_hamming_weight: float = 0.5
chi_square_optimization: bool = True
min_bit_bias = 1e-05
max_bit_correlation = 0.0001
enable_case_aware_mixing: bool = False
case_sensitivity_boost: float = 1.0
ascii_case_amplification: float = 1.0
case_diffusion_factor: float = 0.0
property security_level: str
property expected_performance_ms: float

Beklenen performans (gerçek dünya ölçümü)

property avalanche_target: float
to_dict()[source]
Return type:

Dict[str, Any]

class kha256.OptimizedFortifiedConfig(cache_enabled=True, cache_size=256, enable_metrics=True, double_hashing=False, enable_byte_distribution_optimization=True, byte_uniformity_rounds=5, hash_bytes=32, salt_length=16, **kwargs)[source]

Bases: FortifiedConfig

Configuration for performance-optimized KHA-256 hashing. Extends the base FortifiedConfig with optimization-specific settings.

Parameters:
  • cache_enabled (bool)

  • cache_size (int)

  • enable_metrics (bool)

  • double_hashing (bool)

  • enable_byte_distribution_optimization (bool)

  • byte_uniformity_rounds (int)

  • hash_bytes (int)

  • salt_length (int)

property max_cache_size: int

Alias for cache_size for backward compatibility

class kha256.MemoryHardConfig(output_bits=256, hash_bytes=32, iterations=4, rounds=6, components_per_hash=32, salt_length=32, shuffle_layers=5, diffusion_rounds=6, avalanche_boosts=4, use_enhanced_avalanche=True, enable_quantum_mix=True, enable_diffusion_mix=True, triple_compression=False, memory_hardening=True, enable_byte_distribution_optimization=True, byte_uniformity_rounds=4, time_varying_salt=True, context_sensitive_mixing=True, enable_side_channel_resistance=True, enable_constant_time_ops=True, enable_arithmetic_blinding=True, memory_cost=<property object>, memory_cost_kb=1024, time_cost=2, parallelism=1, _legacy_memory_cost=None, cache_enabled=True, cache_size=512, cache_ttl=None, cache_hmac_protected=True, cache_deterministic=True, parallel_processing=False, max_workers=1, enable_memory_hard_mode=False, double_hashing=False, enable_encryption_layer=True, encryption_rounds=3, enable_hamming_weight_balancing=False, target_hamming_weight=0.5, chi_square_optimization=True, enable_case_aware_mixing=False, case_sensitivity_boost=1.0, ascii_case_amplification=1.0, case_diffusion_factor=0.0)[source]

Bases: FortifiedConfig

Gerçek memory-hard implementasyon için kritik parametreler. Argon2i/Balloon hashing prensiplerine uygun.

Parameters:
  • output_bits (int)

  • hash_bytes (int)

  • iterations (int)

  • rounds (int)

  • components_per_hash (int)

  • salt_length (int)

  • shuffle_layers (int)

  • diffusion_rounds (int)

  • avalanche_boosts (int)

  • use_enhanced_avalanche (bool)

  • enable_quantum_mix (bool)

  • enable_diffusion_mix (bool)

  • triple_compression (bool)

  • memory_hardening (bool)

  • enable_byte_distribution_optimization (bool)

  • byte_uniformity_rounds (int)

  • time_varying_salt (bool)

  • context_sensitive_mixing (bool)

  • enable_side_channel_resistance (bool)

  • enable_constant_time_ops (bool)

  • enable_arithmetic_blinding (bool)

  • memory_cost (int)

  • memory_cost_kb (int)

  • time_cost (int)

  • parallelism (int)

  • _legacy_memory_cost (int | None)

  • cache_enabled (bool)

  • cache_size (int)

  • cache_ttl (int | None)

  • cache_hmac_protected (bool)

  • cache_deterministic (bool)

  • parallel_processing (bool)

  • max_workers (int)

  • enable_memory_hard_mode (bool)

  • double_hashing (bool)

  • enable_encryption_layer (bool)

  • encryption_rounds (int)

  • enable_hamming_weight_balancing (bool)

  • target_hamming_weight (float)

  • chi_square_optimization (bool)

  • enable_case_aware_mixing (bool)

  • case_sensitivity_boost (float)

  • ascii_case_amplification (float)

  • case_diffusion_factor (float)

memory_cost_kb: int = 2048
time_cost: int = 4
parallelism: int = 1
enable_sequential_memory_fill: bool = True
enable_memory_dependency_chain: bool = True
memory_access_pattern: str = 'argon2i'
target_memory_bandwidth_utilization: float = 0.85
max_cpu_utilization: float = 0.3
cache_enabled: bool = False
parallel_processing: bool = False
max_workers: int = 1
class kha256.TrueMemoryHardConfig(output_bits=256, hash_bytes=32, iterations=4, rounds=6, components_per_hash=32, salt_length=32, shuffle_layers=5, diffusion_rounds=6, avalanche_boosts=4, use_enhanced_avalanche=True, enable_quantum_mix=True, enable_diffusion_mix=True, triple_compression=False, memory_hardening=True, enable_byte_distribution_optimization=True, byte_uniformity_rounds=4, time_varying_salt=True, context_sensitive_mixing=True, enable_side_channel_resistance=True, enable_constant_time_ops=True, enable_arithmetic_blinding=True, memory_cost=<property object>, memory_cost_kb=1024, time_cost=2, parallelism=1, _legacy_memory_cost=None, cache_enabled=True, cache_size=512, cache_ttl=None, cache_hmac_protected=True, cache_deterministic=True, parallel_processing=False, max_workers=1, enable_memory_hard_mode=False, double_hashing=False, enable_encryption_layer=True, encryption_rounds=3, enable_hamming_weight_balancing=False, target_hamming_weight=0.5, chi_square_optimization=True, enable_case_aware_mixing=False, case_sensitivity_boost=1.0, ascii_case_amplification=1.0, case_diffusion_factor=0.0)[source]

Bases: FortifiedConfig

Gerçek memory-hard için zorunlu ayarlar

Parameters:
  • output_bits (int)

  • hash_bytes (int)

  • iterations (int)

  • rounds (int)

  • components_per_hash (int)

  • salt_length (int)

  • shuffle_layers (int)

  • diffusion_rounds (int)

  • avalanche_boosts (int)

  • use_enhanced_avalanche (bool)

  • enable_quantum_mix (bool)

  • enable_diffusion_mix (bool)

  • triple_compression (bool)

  • memory_hardening (bool)

  • enable_byte_distribution_optimization (bool)

  • byte_uniformity_rounds (int)

  • time_varying_salt (bool)

  • context_sensitive_mixing (bool)

  • enable_side_channel_resistance (bool)

  • enable_constant_time_ops (bool)

  • enable_arithmetic_blinding (bool)

  • memory_cost (int)

  • memory_cost_kb (int)

  • time_cost (int)

  • parallelism (int)

  • _legacy_memory_cost (int | None)

  • cache_enabled (bool)

  • cache_size (int)

  • cache_ttl (int | None)

  • cache_hmac_protected (bool)

  • cache_deterministic (bool)

  • parallel_processing (bool)

  • max_workers (int)

  • enable_memory_hard_mode (bool)

  • double_hashing (bool)

  • enable_encryption_layer (bool)

  • encryption_rounds (int)

  • enable_hamming_weight_balancing (bool)

  • target_hamming_weight (float)

  • chi_square_optimization (bool)

  • enable_case_aware_mixing (bool)

  • case_sensitivity_boost (float)

  • ascii_case_amplification (float)

  • case_diffusion_factor (float)

memory_cost_kb: int = 2048
time_cost: int = 4
parallelism: int = 1
cache_enabled: bool = False
parallel_processing: bool = False
max_workers: int = 1
enable_memory_hard_fill: bool = True
memory_fill_algorithm: str = 'argon2i'
double_hashing: bool = False
triple_compression: bool = False
target_memory_bandwidth_utilization: float = 0.85
class kha256.SecurityConstants[source]

Bases: object

NIST SP 800-132 ve SP 800-90B standartlarına uygun sabitler

MIN_SALT_LENGTH = 16
MIN_KEY_LENGTH = 32
MIN_ITERATIONS = 2
MIN_ROUNDS = 4
MEMORY_COST = 1024
MEMORY_COST_KB = 1024
TIME_COST = 4
PARALLELISM = 1
class kha256.SecurityLayers[source]

Bases: object

Çok katmanlı güvenlik katmanları

static constant_time_compare(a, b)[source]

Zaman sabit byte karşılaştırması

Parameters:
Return type:

bool

static timing_attack_protection(func)[source]

Zamanlama saldırılarına karşı koruma dekoratörü

static arithmetic_blinding(value, bits=64)[source]

Aritmetik işlemler için körleme

Parameters:
Return type:

int

static secure_memory_zero(buffer)[source]

Belleği güvenli şekilde sıfırla

Parameters:

buffer (bytearray)

static apply_constant_time_operations(config)[source]

Zaman sabit operasyonları uygula

class kha256.MathematicalSecurityBases[source]

Bases: object

Güçlendirilmiş matematiksel güvenlik sabitleri ve fonksiyonları (Kripto için optimize)

SECURITY_CONSTANTS = {'aes_sbox_rot': 0.058823529411764705, 'apery': 1.2020569031595942, 'catalan': 0.915965594177219, 'champernowne': 0.12345678910111213, 'euler_mascheroni': 0.5772156649015329, 'feigenbaum_1': 4.66920160910299, 'feigenbaum_2': 2.5029078750958926, 'fine_structure': 0.0072973525643, 'gauss': 0.8346268416740732, 'glaisher': 1.2824271291006226, 'golden_ratio': 1.618033988749895, 'gompertz': 0.5963473623231941, 'kececi_constant': 2.23606797749979, 'kha_e': 2.718281828459045, 'kha_pi': 3.141592653589793, 'khinchin': 2.6854520010653062, 'lemniscate': 2.6220575542921196, 'liouville': 0.110001, 'mills_constant': 1.3063778838630806, 'octonion_e1': 1.0, 'octonion_e2': 0.0, 'oktonyon_e1': 1.0, 'oktonyon_e2': 0.0, 'oktonyon_e3': 0.0, 'oktonyon_e4': 0.0, 'oktonyon_e5': 0.0, 'oktonyon_e6': 0.0, 'oktonyon_e7': 0.0, 'oktonyon_e8': 0.0, 'planck_h': 6.62607015e-34, 'plastic_number': 1.324717957244746, 'poly1305_r': 862770444666299893, 'quantum_constant': 1.5707963267948966, 'ramanujan_soldner': 1.451369234883381, 'security_phi': 1.381966011250105, 'sha3_rc0': 1, 'silver_ratio': 2.414213562373095, 'sqrt_2': 1.4142135623730951, 'sqrt_3': 1.7320508075688772, 'sqrt_5': 2.23606797749979, 'supergolden_ratio': 1.465571231876768, 'tau': 6.283185307179586, 'tribonacci_constant': 1.8392867552141612, 'zeta_2': 1.6449340668482264, 'zeta_3': 1.2020569031595942}
TRANSFORMATIONS = [<function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>, <function MathematicalSecurityBases.<lambda>>]
static get_constant(name, offset=0)[source]

Güvenlik sabiti al

Parameters:
Return type:

float

static apply_transformations(*args, **kwargs)[source]
static generate_secure_matrix(seed, size=512)[source]

Güvenli matris oluştur

Parameters:
Return type:

ndarray

class kha256.ByteDistributionOptimizer[source]

Bases: object

Byte dağılımını iyileştirici

static optimize_byte_distribution(hash_bytes, rounds=3)[source]

Byte dağılımını optimize et

Parameters:
Return type:

bytes

static calculate_byte_uniformity(data)[source]

Byte uniformluğunu hesapla (0-1, 1=en iyi)

Parameters:

data (bytes)

Return type:

float

class kha256.TransformFunctions[source]

Bases: object

KHA-256 ÖZEL DÖNÜŞÜM FONKSİYONLARI

static f1(x)[source]
Parameters:

x (int)

Return type:

int

static f2(x)[source]
Parameters:

x (int)

Return type:

int

static f3(x)[source]
Parameters:

x (int)

Return type:

int

static f4(x)[source]
Parameters:

x (int)

Return type:

int

static chaos(x)[source]
Parameters:

x (int)

Return type:

int

static mix3(a, b, c)[source]
Parameters:
Return type:

int

static mix4(a, b, c, d)[source]
Parameters:
Return type:

int

class kha256.HardwareSecurityID(use_mac=False, salt=None)[source]

Bases: object

Parameters:
  • use_mac (bool) – MAC adresini dahil et (varsayılan: False → GDPR uyumlu)

  • salt (Optional[bytes]) – Tersine mühendislik koruması için sabit salt (isteğe bağlı)

get_hardware_id()[source]

KHA256 ile deterministik HWID üretimi

Return type:

str

class kha256.HardwareSecurityID2[source]

Bases: object

get_hardware_id()[source]
Return type:

str

class kha256.KHAcache(max_size=512, deterministic=True)[source]

Bases: object

KHA-256 için güvenli, HMAC korumalı cache sistemi. Cache poisoning ve timing attack’lara karşı korumalı.

Parameters:
  • max_size (int)

  • deterministic (bool)

__init__(max_size=512, deterministic=True)[source]
Parameters:
  • max_size (int) – Maksimum cache öğe sayısı

  • deterministic (bool) – Deterministik mod (HWID için True)

get(data, salt)[source]

Cache’den hash al. :returns: Hash bytes veya None (cache miss veya integrity hatası)

Parameters:
Return type:

bytes | None

put(data, salt, hash_bytes)[source]

Hash’i cache’e ekle

Parameters:
Return type:

None

clear()[source]

Cache’i temizle

Return type:

None

invalidate(data, salt)[source]

Belirli bir girdiyi cache’den sil

Parameters:
Return type:

bool

property metrics: Dict[str, Any]

Cache metrikleri

class kha256.KHA256Utils[source]

Bases: object

Perfect Avalanche Utilities - OPTIMIZED

static rotr64(x, n)[source]

64-bit rotate right

Parameters:
Return type:

int

static rotl8(x, n)[source]

8-bit rotate left - PERFECT AVALANCHE

Parameters:
Return type:

int

static secure_random(n)[source]

Cryptographic random

Parameters:

n (int)

Return type:

bytes

static bytes_to_words64(b)[source]

Bytes to 64-bit words

Parameters:

b (bytes)

Return type:

List[int]

static bit_diff(h1, h2)[source]

Calculate bit difference between two hashes

Parameters:
Return type:

int

static entropy(data)[source]

Calculate Shannon entropy

Parameters:

data (bytes)

Return type:

float

class kha256.KHAUtils[source]

Bases: object

KHA-256 UTILS

static rotl64(x, n)[source]
Parameters:
Return type:

int

static rotr64(x, n)[source]
Parameters:
Return type:

int

static rotl8(x, n)[source]
Parameters:
Return type:

int

static secure_random(n)[source]
Parameters:

n (int)

Return type:

bytes

static bytes_to_words64(b)[source]
Parameters:

b (bytes)

Return type:

List[int]

static bytes_to_words32(b)[source]
Parameters:

b (bytes)

Return type:

List[int]

static bit_diff(h1, h2)[source]
Parameters:
Return type:

int

class kha256.Kha256SecureStorage[source]

Bases: object

protect(data)[source]

Veriyi salt + len + data + tag ile korur

Parameters:

data (bytes)

Return type:

bytes

verify(stored)[source]

Bütünlüğü doğrular, veri döner

Parameters:

stored (bytes)

Return type:

tuple[bool, bytes]

class kha256.KHA256UnicodeHasher(salt_length=32, log_output=True)[source]

Bases: object

KHA-256 ile Unicode uyumlu hash sınıfı

unicode_hash(metin, mode='fortified', log=None)[source]

Unicode metni KHA-256 ile hash’ler

Parameters:
  • metin (str) – Hash’lenecek Unicode metin

  • mode (str) – ‘fortified’ (saltlı), ‘quick’ (hızlı), ‘default’ (fortified)

  • log (bool) – Log göster (None=class ayarı)

Returns:

64 karakterli hex hash

Return type:

str

new_salt()[source]

Yeni salt üretir

class kha256.SimpleRateLimiter(max_requests=5, window_seconds=60)[source]

Bases: object

Basit bir rate limiter implementasyonu

is_allowed(client_ip)[source]

İsteğe izin veriliyor mu?

get_stats(client_ip=None)[source]

İstatistikleri getir

reset_ip(client_ip)[source]

IP’nin limitlerini sıfırla

class kha256.RateLimiterDemoUI[source]

Bases: object

Jupyter için interaktif rate limiter demo arayüzü

display()[source]

UI’yi göster

class kha256.SecureLoginSystem(max_requests=5, window_seconds=60)[source]

Bases: object

Rate limiting ile güvenli login sistemi

login_attempt(client_ip, username, password)[source]

Rate limiting ile güvenli login

get_stats()[source]

Sistem istatistiklerini getir

reset_system()[source]

Sistemi sıfırla

class kha256.MockAuthSystem[source]

Bases: object

Mock kimlik doğrulama sistemi

authenticate(username, password)[source]

Kullanıcıyı doğrula

get_user_info(username)[source]

Kullanıcı bilgilerini getir

class kha256.MemoryHardDemo[source]

Bases: object

Memory-hard hash demo sınıfı - DÜZELTİLMİŞ

users_db: Dict[str, dict]
mock_memory_hard_hash(data, salt, memory_kb=8192)[source]

Mock memory-hard hash fonksiyonu Gerçek TrueMemoryHardHasher çok daha yavaş olur (~580ms)

Parameters:
Return type:

str

normal_hash(data, salt)[source]

Normal hash (SHA-256)

Parameters:
Return type:

str

demo_registration()[source]

Kullanıcı kayıt demo

demo_login()[source]

Kullanıcı giriş demo

demo_brute_force_analysis()[source]

Brute-force analizi demo

demo_performance()[source]

Performans karşılaştırma demo - DETERMINISTIC!

demo_security_levels()[source]

Güvenlik seviyeleri demo - SABİT SALT

list_users()[source]

Kayıtlı kullanıcıları listele

interactive_menu()[source]

Etkileşimli menü

show_info()[source]

Memory-hard hakkında bilgi

kha256.secure_hash_password(password)[source]

Production şifre hashing — NIST SP 800-63B, OWASP uyumlu.

Parameters:

password (str)

Return type:

str

kha256.safe_hash_password(password, salt=None)[source]

Güvenli hash_password wrapper - her çağrıda farklı salt kullan

Parameters:
Return type:

str

kha256.hash_password(data, salt, *, is_usb_key=True, fast_mode=False)[source]

SCrypt KHA - Salt ZORUNLU, USB varsayılan (2026 güvenli)

Parameters:
Return type:

str

kha256.hash_password_str(password, salt, **kwargs)[source]

String wrapper - salt ZORUNLU

Parameters:
Return type:

str

kha256.verify_password(stored_hash, password)[source]

Her iki tür hash’i de doğrulayabilen universal fonksiyon

Parameters:
  • stored_hash (str)

  • password (str)

Return type:

bool

kha256.batch_hash_secure(passwords)[source]

Güvenli batch password hashing (Argon2id).

Parameters:

passwords (list[str])

Return type:

list[str]

kha256.batch_hash_xxh64(passwords)[source]

Hızlı batch hashing (non-kriptografik, benchmark için).

Parameters:

passwords (list[str])

Return type:

list[int]

kha256.quick_hash(data)[source]

Hızlı ve güvenli 256-bit hash (BLAKE2b). Python 3.11+ optimize edilmiş, kriptografik ama KDF değildir.

Parameters:

data (str | bytes)

Return type:

str

kha256.quick_hash_raw(data)[source]

BLAKE3 raw bytes (hex dönüşümü yok → %45 daha hızlı).

Parameters:

data (str | bytes)

Return type:

bytes

kha256.quick_hash_sha256(data)[source]

SHA-256 (256-bit) - Fallback olarak kullanılır.

Parameters:

data (str | bytes)

Return type:

str

kha256.quick_hash_blake3(data)[source]

BLAKE3 - En hızlı kriptografik hash (256-bit varsayılan).

Parameters:

data (str | bytes)

Return type:

str

kha256.quick_hash_128(data)[source]

BLAKE3 128-bit output (32 karakter hex).

Parameters:

data (str | bytes)

Return type:

str

kha256.safe_quick_hash(data)[source]

Güvenli quick_hash wrapper

Return type:

str

kha256.ultra_fast_hash(data)[source]

xxHash64 - En hızlı non-kriptografik hash. NOT: 64-bit output üretir (256-bit DEĞİL). Sadece cache/index için kullanın.

Parameters:

data (str | bytes)

Return type:

int

kha256.ultra_fast_hash_hex(data)[source]

xxHash64 - hex formatında

kha256.ultra_fast_hash_int_to_hex(data)[source]

xxHash64 - integer’ı hex’e çevir

kha256.fast_hash_int(data)[source]

xxHash64 integer — cache key/index için ideal. Ubuntu 25.10’de ~130 ns/op.

Parameters:

data (str | bytes)

Return type:

int

kha256.fastest_cache_key(data)[source]

String için optimize edilmiş cache key (xxHash64).

Parameters:

data (str)

Return type:

int

kha256.xxh64_hash(data)[source]

xxHash64 hexdigest output (non-kriptografik).

Parameters:

data (str | bytes)

Return type:

str

kha256.fnv1a_64(data)[source]

64-bit FNV-1a - dependency-free, non-kriptografik.

Parameters:

data (str | bytes)

Return type:

str

kha256.djb2_optimized(data)[source]

DJB2 - micro-optimized pure Python.

Parameters:

data (str | bytes)

Return type:

int

kha256.shake256_hash(data, output_length=32)[source]

SHAKE256 değişken çıktı uzunluklu hash fonksiyonu.

Parameters:
  • data – Hash’lenecek veri (bytes veya string)

  • output_length – İstenen çıktı uzunluğu (bytes cinsinden)

Returns:

Belirtilen uzunlukta hash değeri

Return type:

bytes

Raises:

ValueError – output_length negatif veya çok büyükse

kha256.shake256_128(data)[source]

128 bit (16 byte) SHAKE256 hash

kha256.shake256_256(data)[source]

256 bit (32 byte) SHAKE256 hash

kha256.shake256_512(data)[source]

512 bit (64 byte) SHAKE256 hash

kha256.gizli_turkce_hash(metin, gizli_mod='🔒ZİNCİR')[source]

KHA-256 + Türkçe karakter zinciri + ZORUNLU SALT

kha256.fixed_gfh_password(iterations=3, memory_cost_kb=1024, time_cost=2)[source]

FIX: Config’i gerçekten kullanan versiyon

kha256.hash_argon2id(password)[source]

Production-ready password hashing (Argon2id - en güvenli seçenek). Output: 256-bit+ encoded hash.

Parameters:

password (str)

Return type:

str

kha256.hash_bcrypt(password, rounds=12)[source]

bcrypt password hashing (adaptive cost). Output: ~184-bit effective security (yeterli).

Parameters:
Return type:

str

kha256.hash_pbkdf2(password, salt=None, iterations=600000)[source]

PBKDF2-HMAC-SHA256 (NIST önerilen). Output: 256-bit key + salt.

Parameters:
Return type:

str

kha256.hwid_hash(data)[source]

HWID üretimi için optimize edilmiş hash. Ubuntu 25.10’de Intel SHA Extensions ile ~280 ns/op.

Parameters:

data (str | bytes)

Return type:

str

kha256.generate_hwid(components)[source]

Deterministik HWID üretimi — kriptografik olarak güvenli. Ubuntu 25.10’de Intel SHA Extensions ile ~0.3 µs/op.

Parameters:

components (Dict[str, str] | str | bytes) – Donanım bileşenleri dict’i veya raw string/bytes

Returns:

64 karakterlik SHA-256 hex string (256-bit)

Return type:

str

kha256.generate_compact_hwid(components)[source]

Compact HWID (32 byte raw) — storage optimizasyonu için. Hex string yerine %50 daha az yer kaplar.

Parameters:

components (Dict[str, str])

Return type:

bytes

kha256.generate_secure_hwid(components, salt='my_app_salt_v1')[source]

HWID + sabit salt → tersine mühendislik koruması

Parameters:
Return type:

str

kha256.simple_hmac(key, message)[source]
Parameters:
Return type:

bytes

kha256.image_signature(image_array, secret_key, deterministic=False)[source]

Bir numpy görüntü dizisinin (RGB uint8) KHA-256 özetini döndürür. deterministic=True ise salt kullanılmaz (sabit çıktı).

Parameters:
  • image_array (ndarray)

  • secret_key (bytes)

  • deterministic (bool)

Return type:

str

kha256.run_all_tests()[source]

Bütün memory-hard sınıfı testlerini çalıştırır

kha256.run_cli_demo()[source]

Komut satırı demo

kha256.run_comprehensive_test()[source]

Kapsamlı güvenlik testi

kha256.run_comprehensive_test_suite()[source]

Kapsamlı test paketini çalıştır

Return type:

Dict[str, Any]

kha256.performance_comparison()[source]

Memory-hard vs normal hash performans karşılaştırması

kha256.economic_analysis(memory_mb=8, time_ms=580)[source]

Memory-hard hash’lerin ekonomik analizi GPU/ASIC saldırılarına karşı maliyet etkinliği

kha256.secure_password_hashing(password, salt=None)[source]

Güvenli parola hash’leme için minimum ayarlar

kha256.show_rate_limiter_info()[source]

Rate limiter hakkında bilgi

class kha256.db[source]

Bases: object

database manager

thread_local = <_thread._local object>
get_db_connection()[source]

Thread-safe veritabanı bağlantısı için context manager

setup_database()[source]

Veritabanını kur

save_user(password, retry_count=3)[source]

Kullanıcıyı veritabanına kaydet

verify_user(password, retry_count=3)[source]

Kullanıcıyı doğrula

list_users()[source]

Kayıtlı kullanıcıları listele

delete_user()[source]

Kullanıcıyı sil

close_all_connections()[source]

Tüm veritabanı bağlantılarını kapat

widgets = <module 'ipywidgets' from '/home/mk/conda/envs/a14/lib/python3.14/site-packages/ipywidgets/__init__.py'>
class HTML(data=None, url=None, filename=None, metadata=None)

Bases: TextDisplayObject

clear_output()

Clear the output of the current cell receiving output.

Parameters:

wait (bool [default: false]) – Wait to clear the output until new output is available to replace it.

display(*, include=None, exclude=None, metadata=None, transient=None, display_id=None, raw=False, clear=False, **kwargs)

Display a Python object in all frontends.

By default all representations will be computed and sent to the frontends. Frontends can decide which representation is used and how.

In terminal IPython this will be similar to using print(), for use in richer frontends see Jupyter notebook examples with rich display logic.

Parameters:
  • *objs (object) – The Python objects to display.

  • raw (bool, optional) – Are the objects to be displayed already mimetype-keyed dicts of raw display data, or Python objects that need to be formatted before display? [default: False]

  • include (list, tuple or set, optional) – A list of format type strings (MIME types) to include in the format data dict. If this is set only the format types included in this list will be computed.

  • exclude (list, tuple or set, optional) – A list of format type strings (MIME types) to exclude in the format data dict. If this is set all format types will be computed, except for those included in this argument.

  • metadata (dict, optional) – A dictionary of metadata to associate with the output. mime-type keys in this dictionary will be associated with the individual representation formats, if they exist.

  • transient (dict, optional) – A dictionary of transient data to associate with the output. Data in this dict should not be persisted to files (e.g. notebooks).

  • display_id (str, bool optional) – Set an id for the display. This id can be used for updating this display area later via update_display. If given as True, generate a new display_id

  • clear (bool, optional) – Should the output area be cleared before displaying anything? If True, this will wait for additional output before clearing. [default: False]

  • **kwargs (additional keyword-args, optional) – Additional keyword-arguments are passed through to the display publisher.

Returns:

handle – Returns a handle on updatable displays for use with update_display(), if display_id is given. Returns None if no display_id is given (default).

Return type:

DisplayHandle

Examples

>>> class Json(object):
...     def __init__(self, json):
...         self.json = json
...     def _repr_pretty_(self, pp, cycle):
...         import json
...         pp.text(json.dumps(self.json, indent=2))
...     def __repr__(self):
...         return str(self.json)
...
>>> d = Json({1:2, 3: {4:5}})
>>> print(d)
{1: 2, 3: {4: 5}}
>>> display(d)
{
  "1": 2,
  "3": {
    "4": 5
  }
}
>>> def int_formatter(integer, pp, cycle):
...     pp.text('I'*integer)
>>> plain = get_ipython().display_formatter.formatters['text/plain']
>>> plain.for_type(int, int_formatter)
<function _repr_pprint at 0x...>
>>> display(7-5)
II
>>> del plain.type_printers[int]
>>> display(7-5)
2

See also

update_display()

Notes

In Python, objects can declare their textual representation using the __repr__ method. IPython expands on this idea and allows objects to declare other, rich representations including:

  • HTML

  • JSON

  • PNG

  • JPEG

  • SVG

  • LaTeX

A single object can declare some or all of these representations; all are handled by IPython’s display system.

The main idea of the first approach is that you have to implement special display methods when you define your class, one for each representation you want to use. Here is a list of the names of the special methods and the values they must return:

  • _repr_html_: return raw HTML as a string, or a tuple (see below).

  • _repr_json_: return a JSONable dict, or a tuple (see below).

  • _repr_jpeg_: return raw JPEG data, or a tuple (see below).

  • _repr_png_: return raw PNG data, or a tuple (see below).

  • _repr_svg_: return raw SVG data as a string, or a tuple (see below).

  • _repr_latex_: return LaTeX commands in a string surrounded by “$”,

    or a tuple (see below).

  • _repr_mimebundle_: return a full mimebundle containing the mapping

    from all mimetypes to data. Use this for any mime-type not listed above.

The above functions may also return the object’s metadata alonside the data. If the metadata is available, the functions will return a tuple containing the data and metadata, in that order. If there is no metadata available, then the functions will return the data only.

When you are directly writing your own classes, you can adapt them for display in IPython by following the above approach. But in practice, you often need to work with existing classes that you can’t easily modify.

You can refer to the documentation on integrating with the display system in order to register custom formatters for already existing types (integrating_rich_display).

Added in version 5.4: display available without import

Added in version 6.1: display available without import

Since IPython 5.4 and 6.1 display() is automatically made available to the user without import. If you are using display in a document that might be used in a pure python context or with older version of IPython, use the following import at the top of your file:

from IPython.display import display
interactive_demo()[source]

Jupyter’da interaktif demo

kha256.test_shake256()[source]

SHAKE256 fonksiyonlarını test et

kha256.test_kha256_main()[source]

KHA256 ana sınıf testi

kha256.test_kha256b()[source]

KHA256b - Perfect Avalanche sınıfı

kha256.test_khautils()[source]

KHAUtils testi

kha256.test_basic_functionality()[source]

Temel fonksiyonellik testleri

Return type:

Dict[str, Any]

kha256.test_core_hash()[source]

CoreHash testi

kha256.test_deterministic_hash()[source]

DeterministicHash / DeterministicEngine testi

kha256.test_memory_hard_engine()[source]

MemoryHardEngine testi - YENİ EKLENDİ

kha256.test_memory_hard_hash()[source]

MemoryHardHash testi

kha256.test_memory_hard_real()[source]

Memory-hard’in GERÇEKTEN çalıştığını test et - DÜZELTİLDİ

kha256.test_memory_hardness(hasher, password, salt)[source]

Gerçek memory-hard doğrulama testi NIST SP 800-63B ve RFC 9106 kriterlerine uygun

Parameters:
kha256.test_true_memory_hard()[source]

TrueMemoryHardHasher testi

kha256.test_true_memory_hard_direct()[source]

TrueMemoryHardHasher’ı DIRECT test et!

kha256.test_fortified_hashers()[source]

Tüm fortified hasher’ları import kha256’dan çekip test eder. Her config için: süre (ms), RAM (MB), hash kalitesi

Return type:

Dict[str, Dict[str, Any]]

kha256.test_fortified_memory_hard()[source]

FortifiedKhaHash256 memory-hard test

kha256.test_fortified_memory_hard2()[source]

FortifiedKhaHash256 testi

kha256.test_fortified_memory_hard_fixed()[source]

FortifiedKhaHash256 memory-hard test

kha256.test_hmac()[source]

HMAC test fonksiyonu

kha256.test2_hmac()[source]

HMAC testi

kha256.test_streaming()[source]

Streaming hash testi - KESİN ÇÖZÜM SADECE buffer modu - %100 çalışıyor!

kha256.test2_streaming()[source]

StreamingKHA256 testi

kha256.test_avalanche(kha, iterations=200)[source]

Basit avalanche testi

Parameters:
kha256.test2_avalanche()[source]

Avalanche etkisi testi

kha256.test_edge_cases()[source]

Edge case testleri

Return type:

Dict[str, Any]

kha256.test_parameter_impact()[source]
kha256.test_performance_scenarios()[source]

Performans senaryo testleri

Return type:

Dict[str, Any]

kha256.test_real_world_scenarios()[source]

Gerçek dünya senaryo testleri

Return type:

Dict[str, Any]

kha256.test_security_scenarios()[source]

Güvenlik senaryo testleri

Return type:

Dict[str, Any]

kha256.avalanche_test(hasher, base_data, salt, num_tests=100)[source]

Avalanche etkisi testi - tek bit değişiminin etkisi

Parameters:
kha256.comprehensive_avalanche_test(hasher, base_data, salt)[source]

Tüm bit pozisyonlarını test et - DÜZELTİLMİŞ HEATMAP

Parameters:
kha256.detailed_avalanche_test(hasher, base_data, salt, num_tests=1000)[source]

Detaylı avalanche analizi - bit_diff’leri toplar

Parameters:
kha256.cig_test(kha2, data=b'KHA-256 Perfect Avalanche', iterations=200)[source]

Perfect Avalanche Test - Certified

Parameters:
Return type:

Tuple[float, List[int]]

kha256.gpu_resistance_test(hasher, count=100)[source]

GPU direncini ölç: Gerçek memory-hard ise 100 hash >5 sn sürmeli

kha256.min_entropy_test(byte_data)[source]
Parameters:

byte_data (bytes)

Return type:

float

kha256.diagnose_memory_hardness()[source]
kha256.benchmark_real_cost()[source]

time_cost ve workers’ı override test

kha256.plot_avalanche_distribution(bit_diffs)[source]

Avalanche dağılımını görselleştir

kha256.safe_heatmap_plot(bit_diffs, base_data_length)[source]

Güvenli heatmap oluşturma - hata kontrolü ile

kha256.plot_avalanche_simple(bit_diffs)[source]

Basit avalanche grafiği

class kha256.HKDF(algorithm, length, salt=None, info=None, backend=None)

Bases: object

derive(key_material)
derive_into(key_material, buf)
static extract(algorithm, salt, key_material)
verify(key_material, expected_key)
kha256.secure_compare(a, b)[source]
Parameters:
Return type:

bool

kha256.xor_bytes(a, b)[source]
Parameters:
Return type:

bytes

kha256.bytes_to_int(b)[source]
Parameters:

b (bytes)

Return type:

int

kha256.int_to_bytes(i, length=4)[source]
Parameters:
Return type:

bytes

kha256.cal_bit_difference(hash1, hash2)[source]

İki hex hash arasındaki farklı bit sayısını hesapla

Parameters:
Return type:

int

kha256.calculate_bit_difference(hash1, hash2)[source]

İki hex hash arasındaki farklı bit sayısını hesapla

Parameters:
Return type:

int

kha256.chacha_avalanche_mix(data, salt)[source]

ChaCha20 quarter rounds - kanıtlanmış diffusion

Parameters:
Return type:

bytes

kha256.secure_avalanche_mix(data, salt)[source]

NIST onaylı, deterministik, side-channel safe mixing

Parameters:
Return type:

bytes

kha256.expose_kha256_bug()[source]

Benchmark

kha256.generate_fortified_hasher(config=None, deterministic=True, purpose='balanced')[source]

Harmonize edilmiş: Önceki config ile %100 uyumlu

Parameters:

purpose (str)

Return type:

FortifiedKhaHash256

kha256.generate_fortified_hasher_fast(*, iterations=2, components=24, memory_cost_kb=1024, time_cost=2)[source]

Parametrik Fortified KHA-256 oluşturucu.

Parameters:
  • iterations (int)

  • components (int)

  • memory_cost_kb (int)

  • time_cost (int)

Return type:

FortifiedKhaHash256

kha256.generate_fortified_hasher_secure(*, iterations=4, components=64, memory_cost_kb=1024, time_cost=5)[source]

Parametrik Fortified KHA-256 oluşturucu.

Parameters:
  • iterations (int)

  • components (int)

  • memory_cost_kb (int)

  • time_cost (int)

Return type:

FortifiedKhaHash256

kha256.generate_fortified_hasher_password(*, iterations=5, components=48, memory_cost_kb=2048, time_cost=4)[source]

Parametrik Fortified KHA-256 oluşturucu.

Parameters:
  • iterations (int)

  • components (int)

  • memory_cost_kb (int)

  • time_cost (int)

Return type:

FortifiedKhaHash256

kha256.get_hasher_config(purpose='password')[source]
Parameters:

purpose (str)

Return type:

FortifiedConfig

kha256.measure_hash(func, *args)[source]

Hassas timing ölçümü (milisaniye cinsinden).

Return type:

tuple[float, any]

kha256.measure_time(func, warmup=3, iterations=10)[source]

Hassas zaman ölçümü (ısınma turu + ortalama)

kha256.debug_configs()[source]

Config’lerin gerçekten farklı olduğunu doğrula

kha256.lru_cache(maxsize=128, typed=False)[source]

Least-recently-used cache decorator.

If maxsize is set to None, the LRU features are disabled and the cache can grow without bound.

If typed is True, arguments of different types will be cached separately. For example, f(decimal.Decimal(“3.0”)) and f(3.0) will be treated as distinct calls with distinct results. Some types such as str and int may be cached separately even when typed is false.

Arguments to the cached function must be hashable.

View the cache statistics named tuple (hits, misses, maxsize, currsize) with f.cache_info(). Clear the cache and statistics with f.cache_clear(). Access the underlying function with f.__wrapped__.

See: https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)

kha256.print_error(text)[source]
Parameters:

text (str)

kha256.print_header(text, width=70)[source]
Parameters:
kha256.print_info(text)[source]
Parameters:

text (str)

kha256.print_results_table(results)[source]

Güzel tablo çıktısı

Parameters:

results (Dict[str, Dict[str, Any]])

kha256.print_subheader(text)[source]
Parameters:

text (str)

kha256.print_success(text)[source]
Parameters:

text (str)

kha256.print_warning(text)[source]
Parameters:

text (str)

kha256.kha_rastgele_sayi(min_deger=0, max_deger=100)[source]
kha256.rastgele_sayi(min_deger=0, max_deger=100)[source]
kha256.kha256_fortified_random(min_deger=0, max_deger=100)[source]
kha256.kha256_password_random(password, min_deger=0, max_deger=100)[source]
Parameters:

password (str)

kha256.kha256_memory_hard_random(min_deger=0, max_deger=100)[source]
kha256.kha256_hard_random(min_deger=0, max_deger=100)[source]
kha256.true_memory_hard_random(min_deger=0, max_deger=100)[source]
kha256.memory_hard_hash_random(min_deger=0, max_deger=100)[source]
kha256.memory_hard_engine_random(min_deger=0, max_deger=100)[source]
kha256.fortified_kha_random(min_deger=0, max_deger=100)[source]
kha256.kha256b_random(min_deger=0, max_deger=100)[source]
kha256.scrypt_random(min_deger=0, max_deger=100)[source]
kha256.gscrypt_random(min_deger=0, max_deger=100)[source]
kha256.bscrypt_random(min_deger=0, max_deger=100)[source]
kha256.scrypt_dual_output(min_deger=0, max_deger=100)[source]
kha256.is_jupyter()[source]
kha256.silent_kn()[source]

kececinumbers’ı sustur - hiçbir log, hiçbir print gelmez!

class kha256.Colors[source]

Bases: object

GREEN = '\x1b[92m'
YELLOW = '\x1b[93m'
RED = '\x1b[91m'
BLUE = '\x1b[94m'
MAGENTA = '\x1b[95m'
CYAN = '\x1b[96m'
WHITE = '\x1b[97m'
RESET = '\x1b[0m'
BOLD = '\x1b[1m'
UNDERLINE = '\x1b[4m'
kha256.legacy_function()[source]

Legacy function scheduled for removal.

Return type:

None

Submodules