kha256.kha256 module
KHA-256 (Keçeci Hash Algorithm)
KEÇECİ HASH ALGORITHM (KEÇECİ HASH ALGORİTMASI), KHA-256 A cryptographic hash algorithm. 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
# pip install -U bcrypt kececinumbers blake3 pycryptodome xxhash argon2-cffi pandas numpy cryptography ipywidgets ipython scipy # conda install -c conda-forge kececinumbers bcrypt blake3 pycryptodome xxhash argon2-cffi pandas numpy cryptography # pip install xxhash: # xxh32 collision riski yüksek (64-bit için ~yüz milyonlarda %0.03)
- kha256.kha256.logger = <Logger kha256.kha256 (INFO)>
Logger for kha256 module.
Examples
>>> import logging >>> logger.info("test")
Notes
Module-level logger instance.
- class kha256.kha256.KHAcache(max_size=512, deterministic=True)[source]
Bases:
objectKHA-256 için güvenli, HMAC korumalı cache sistemi. Cache poisoning ve timing attack’lara karşı korumalı.
- get(data, salt)[source]
Cache’den hash al. :returns: Hash bytes veya None (cache miss veya integrity hatası)
- class kha256.kha256.SecurityConstants[source]
Bases:
objectNIST 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.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:
objectPerformans-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)
- 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ığı)
- property memory_cost
use memory_cost_kb instead
- Type:
Deprecated
- min_bit_bias = 1e-05
- max_bit_correlation = 0.0001
- class kha256.kha256.MemoryHardHash(memory_mb=1, iterations=3)[source]
Bases:
objectKHA-MH - Memory-hard hash
- memory_blocks
- iterations
- class kha256.kha256.KHA256[source]
Bases:
objectKHA-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 ==========================================
- class kha256.kha256.StreamingKHA256(salt=None)[source]
Bases:
objectBü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])
- kha256.kha256.test_streaming()[source]
Streaming hash testi - KESİN ÇÖZÜM SADECE buffer modu - %100 çalışıyor!
- class kha256.kha256.KHAConstants[source]
Bases:
objectPerfect Avalanche Constants - CALIBRATED FOR 128.00/128.00
- IV = [7640891576956012808, 13503953896175478587, 4354685564936845355, 11912009170470909681, 5840696475078001361, 11170449401992604703, 2270897969802886507, 6620516959819538809]
- K = [4794697086780616226, 8158064640168781261, 13096744586834688815, 16840607885511220156, 4131703408338449720, 6480981068601479193, 10538285296894168987, 12329834152419229976, 15566598209576043074, 1334009975649890238, 2608012711638119052, 6128411473006802146, 8268148722764581231, 9286055187155687089, 11230858885718282805, 13951009754708518548, 16472876342353939154, 17275323862435702243, 1135362057144423861, 2597628984639134821, 3308224258029322869, 5365058923640841347, 6679025012923562964, 8573033837759648693, 10970295158949994411, 12119686244451234320, 12683024718118986047, 13788192230050041572, 14330467153632333762, 15395433587784984357, 489312712824947311, 1452737877330783856, 2861767655752347644, 3322285676063803686, 5560940570517711597, 5996557281743188959, 7280758554555802590, 8532644243296465576, 9350256976987008742, 10552545826968843579, 11727347734174303076, 12113106623233404929, 14000437183269869457, 14369950271660146224, 15101387698204529176, 15463397548674623760, 17586052441742319658, 1182934255886127544, 1847814050463011016, 2177327727835720531, 2830643537854262169, 3796741975233480872, 4115178125766777443, 5681478168544905931, 6601373596472566643, 7507060721942968483, 8399075790359081724, 8693463985226723168, 9568029438360202098, 10144078919501101548, 10430055236837252648, 11840083180663258601, 13761210420658862357, 14299343276471374635, 14566680578165727644, 15097957966210449927, 16922976911328602910, 17689382322260857208, 500013540394364858, 748580250866718886, 1242879168328830382, 1977374033974150939, 2944078676154940804, 3659926193048069267, 4368137639120453308, 4836135668995329356, 5532061633213252278, 6448918945643986474, 6902733635092675308, 7801388544844847127]
- MAGIC_PRE = 2
- MAGIC_POST = 1
- class kha256.kha256.KHA256Utils[source]
Bases:
objectPerfect Avalanche Utilities - OPTIMIZED
- class kha256.kha256.MemoryHardEngine(memory_mb=1, iterations=3)[source]
Bases:
objectMemory-hard hash - PERFECT AVALANCHE
- blocks
- iterations
- class kha256.kha256.CoreEngine[source]
Bases:
objectSHA-512 core - PERFECT AVALANCHE 128.00/128.00
- class kha256.kha256.KHA256b[source]
Bases:
object- hash(data, salt=None, *, deterministic=False, memory_hard=False, memory_mb=1)[source]
Compute KHA-256 hash - PERFECT AVALANCHE
- Parameters:
- Returns:
64-character hex hash (256-bit) with PERFECT AVALANCHE
- Return type:
- kha256.kha256.cig_test(kha2, data=b'KHA-256 Perfect Avalanche', iterations=200)[source]
Perfect Avalanche Test - Certified
- class kha256.kha256.TrueMemoryHardHasher(memory_cost_kb, time_cost, parallelism=1)[source]
Bases:
objectNIST 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!
- class kha256.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:
FortifiedConfigGerç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)
- class kha256.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:
FortifiedConfigGerç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)
- kha256.kha256.measure_time(func, warmup=3, iterations=10)[source]
Hassas zaman ölçümü (ısınma turu + ortalama)
- kha256.kha256.test_memory_hardness(hasher, password, salt)[source]
Gerçek memory-hard doğrulama testi NIST SP 800-63B ve RFC 9106 kriterlerine uygun
- class kha256.kha256.ByteDistributionOptimizer[source]
Bases:
objectByte dağılımını iyileştirici
- class kha256.kha256.SecurityLayers[source]
Bases:
objectÇok katmanlı güvenlik katmanları
- class kha256.kha256.MathematicalSecurityBases[source]
Bases:
objectGüç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>>]
- class kha256.kha256.FortifiedKhaCore(config)[source]
Bases:
objectFortified KHA Hash Core Engine
- Parameters:
config (FortifiedConfig)
- class kha256.kha256.PerformanceOptimizedKhaCore(config)[source]
Bases:
FortifiedKhaCorePerformans optimize edilmiş KHA çekirdeği
- Parameters:
config (FortifiedConfig)
- kha256.kha256.test_memory_hard_real()[source]
Memory-hard’in GERÇEKTEN çalıştığını test et - DÜZELTİLDİ
- class kha256.kha256.FortifiedKhaHash256(config=None, *, deterministic=True)[source]
Bases:
objectFortified KHA Hash (KHA-256) - Ultra Secure
- Parameters:
config (Optional[FortifiedConfig])
deterministic (bool)
- KEY_SIZE = 32
- NONCE_SIZE = 12
- property deterministic
Deterministic özelliği için getter
- class kha256.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:
FortifiedConfigConfiguration for performance-optimized KHA-256 hashing. Extends the base FortifiedConfig with optimization-specific settings.
- Parameters:
- class kha256.kha256.HybridKhaHash256(config=None, *, deterministic=True, turbo_mode=True, hybrid_mode=True)[source]
Bases:
FortifiedKhaHash256HYBRID KHA-256 implementation. Uses BLAKE2s for small data, KHA for large data.
- Parameters:
config (Optional[Union[OptimizedFortifiedConfig, FortifiedConfig]])
deterministic (bool)
turbo_mode (bool)
hybrid_mode (bool)
- 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)
- class kha256.kha256.OptimizedKhaHash256(config=None, *, deterministic=True, turbo_mode=True)[source]
Bases:
FortifiedKhaHash256SIMPLE & FAST KHA-256 implementation. No micro-optimizations, just the essentials for speed.
- Parameters:
config (Optional[Union[OptimizedFortifiedConfig, FortifiedConfig]])
deterministic (bool)
turbo_mode (bool)
- __init__(config=None, *, deterministic=True, turbo_mode=True)[source]
Initialize the optimized hasher with minimal overhead.
- Parameters:
config (OptimizedFortifiedConfig | FortifiedConfig | None) – Configuration object
deterministic (bool) – Whether to use deterministic behavior
turbo_mode (bool) – Enable extreme optimizations for speed
- kha256.kha256.generate_fortified_hasher(config=None, deterministic=True, purpose='balanced')[source]
Harmonize edilmiş: Önceki config ile %100 uyumlu
- Parameters:
purpose (str)
- Return type:
- kha256.kha256.generate_fortified_hasher_password(*, iterations=5, components=48, memory_cost_kb=2048, time_cost=4)[source]
Parametrik Fortified KHA-256 oluşturucu.
- Parameters:
- Return type:
- kha256.kha256.generate_fortified_hasher_fast(*, iterations=2, components=24, memory_cost_kb=1024, time_cost=2)[source]
Parametrik Fortified KHA-256 oluşturucu.
- Parameters:
- Return type:
- kha256.kha256.generate_fortified_hasher_secure(*, iterations=4, components=64, memory_cost_kb=1024, time_cost=5)[source]
Parametrik Fortified KHA-256 oluşturucu.
- Parameters:
- Return type:
- kha256.kha256.hash_password(data, salt, *, is_usb_key=True, fast_mode=False)[source]
SCrypt KHA - Salt ZORUNLU, USB varsayılan (2026 güvenli)
- kha256.kha256.quick_hash(data)[source]
Hızlı ve güvenli 256-bit hash (BLAKE2b). Python 3.11+ optimize edilmiş, kriptografik ama KDF değildir.
- kha256.kha256.quick_hash_blake3(data)[source]
BLAKE3 - En hızlı kriptografik hash (256-bit varsayılan).
- kha256.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.
- kha256.kha256.hash_argon2id(password)[source]
Production-ready password hashing (Argon2id - en güvenli seçenek). Output: 256-bit+ encoded hash.
- kha256.kha256.hash_bcrypt(password, rounds=12)[source]
bcrypt password hashing (adaptive cost). Output: ~184-bit effective security (yeterli).
- kha256.kha256.hash_pbkdf2(password, salt=None, iterations=600000)[source]
PBKDF2-HMAC-SHA256 (NIST önerilen). Output: 256-bit key + salt.
- kha256.kha256.batch_hash_xxh64(passwords)[source]
Hızlı batch hashing (non-kriptografik, benchmark için).
- kha256.kha256.fast_hash_int(data)[source]
xxHash64 integer — cache key/index için ideal. Ubuntu 25.10’de ~130 ns/op.
- kha256.kha256.secure_hash_password(password)[source]
Production şifre hashing — NIST SP 800-63B, OWASP uyumlu.
- kha256.kha256.gizli_turkce_hash(metin, gizli_mod='🔒ZİNCİR')[source]
KHA-256 + Türkçe karakter zinciri + ZORUNLU SALT
- class kha256.kha256.KHA256UnicodeHasher(salt_length=32, log_output=True)[source]
Bases:
objectKHA-256 ile Unicode uyumlu hash sınıfı
- class kha256.kha256.Shake256Hasher(output_length=32)[source]
Bases:
objectSHAKE256 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)
- kha256.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:
- Raises:
ValueError – output_length negatif veya çok büyükse
- kha256.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
- kha256.kha256.gpu_resistance_test(hasher, count=100)[source]
GPU direncini ölç: Gerçek memory-hard ise 100 hash >5 sn sürmeli
- kha256.kha256.secure_avalanche_mix(data, salt)[source]
NIST onaylı, deterministik, side-channel safe mixing
- kha256.kha256.chacha_avalanche_mix(data, salt)[source]
ChaCha20 quarter rounds - kanıtlanmış diffusion
- kha256.kha256.test_deterministic_behavior(core, func_name, func, matrix, salt1, salt2)[source]
Deterministik davranışı test et
- class kha256.kha256.DeterministicTest[source]
Bases:
objectDeterministik davranış testleri için hazır sınıf
- SALT1 = b'kha256_deterministic_test_vector_1_2026_32byte!'
- SALT2 = b'kha256_deterministic_test_vector_2_2026_32byte!'
- kha256.kha256.fixed_gfh_password(iterations=3, memory_cost_kb=1024, time_cost=2)[source]
FIX: Config’i gerçekten kullanan versiyon
- kha256.kha256.verify_password(stored_hash, password)[source]
Her iki tür hash’i de doğrulayabilen universal fonksiyon
- kha256.kha256.generate_hwid(components)[source]
Deterministik HWID üretimi — kriptografik olarak güvenli. Ubuntu 25.10’de Intel SHA Extensions ile ~0.3 µs/op.
- kha256.kha256.generate_compact_hwid(components)[source]
Compact HWID (32 byte raw) — storage optimizasyonu için. Hex string yerine %50 daha az yer kaplar.
- kha256.kha256.generate_secure_hwid(components, salt='my_app_salt_v1')[source]
HWID + sabit salt → tersine mühendislik koruması
- kha256.kha256.hwid_hash(data)[source]
HWID üretimi için optimize edilmiş hash. Ubuntu 25.10’de Intel SHA Extensions ile ~280 ns/op.
- kha256.kha256.hwid_hash_cached(data)[source]
Tekrarlayan HWID’ler için cache’li versiyon. Cache hit sonrası ~30 ns/op (11x hızlanma). ⚠️ Sadece STR kullanın — bytes cache anahtarı farklı oluşturur!
- class kha256.kha256.SimpleKhaHasher(salt=None)[source]
Bases:
objectBasit 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.
- class kha256.kha256.SimpleRateLimiter(max_requests=5, window_seconds=60)[source]
Bases:
objectBasit bir rate limiter implementasyonu
- class kha256.kha256.SecureLoginSystem(max_requests=5, window_seconds=60)[source]
Bases:
objectRate limiting ile güvenli login sistemi
- class kha256.kha256.RateLimiterDemoUI[source]
Bases:
objectJupyter için interaktif rate limiter demo arayüzü
- class kha256.kha256.MemoryHardDemo[source]
Bases:
objectMemory-hard hash demo sınıfı - DÜZELTİLMİŞ
- mock_memory_hard_hash(data, salt, memory_kb=8192)[source]
Mock memory-hard hash fonksiyonu Gerçek TrueMemoryHardHasher çok daha yavaş olur (~580ms)
Etkileşimli menü
- class kha256.kha256.db[source]
Bases:
objectdatabase manager
- thread_local = <_thread._local object>
- 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. ReturnsNoneif 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
- kha256.kha256.performance_comparison()[source]
Memory-hard vs normal hash performans karşılaştırması
- kha256.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.kha256.secure_password_hashing(password, salt=None)[source]
Güvenli parola hash’leme için minimum ayarlar
- class kha256.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.kha256.safe_hash_password(password, salt=None)[source]
Güvenli hash_password wrapper - her çağrıda farklı salt kullan
- kha256.kha256.calculate_bit_difference(hash1, hash2)[source]
İki hex hash arasındaki farklı bit sayısını hesapla
- kha256.kha256.cal_bit_difference(hash1, hash2)[source]
İki hex hash arasındaki farklı bit sayısını hesapla
- kha256.kha256.avalanche_test(hasher, base_data, salt, num_tests=100)[source]
Avalanche etkisi testi - tek bit değişiminin etkisi
- kha256.kha256.detailed_avalanche_test(hasher, base_data, salt, num_tests=1000)[source]
Detaylı avalanche analizi - bit_diff’leri toplar
- kha256.kha256.comprehensive_avalanche_test(hasher, base_data, salt)[source]
Tüm bit pozisyonlarını test et - DÜZELTİLMİŞ HEATMAP
- kha256.kha256.safe_heatmap_plot(bit_diffs, base_data_length)[source]
Güvenli heatmap oluşturma - hata kontrolü ile
- class kha256.kha256.Kha256SecureStorage[source]
Bases:
object
- kha256.kha256.func(byte_array, salt=None)
Taşma hatasız, 3 katmanlı kriptografik byte difüzyonu. Güvenli aritmetik için ara hesaplamalar Python int’leri ile yapılır.
- Parameters:
byte_array (ndarray)
salt (bytes)
- Return type:
ndarray
- kha256.kha256.kha256_password_random(password, min_deger=0, max_deger=100)[source]
- Parameters:
password (str)