ECB Mode (ARCH6113)
هذا المحتوى غير متوفر بلغتك بعد.
Key ruby.security.ecb-mode · Severity error · Category security · CWE CWE-327
ECB mode maps identical plaintext blocks to identical ciphertext, leaking data patterns, and is never semantically secure. Use an authenticated mode (GCM).
Incorrect
Section titled “Incorrect”require "openssl"
cipher = OpenSSL::Cipher.new("aes-256-ecb")cipher.encryptcipher.key = keyencrypted = cipher.update(plaintext) + cipher.finalCorrect
Section titled “Correct”require "openssl"
cipher = OpenSSL::Cipher.new("aes-256-gcm")cipher.encryptcipher.key = keyiv = cipher.random_ivencrypted = cipher.update(plaintext) + cipher.finaltag = cipher.auth_tagReplace ECB mode with AES-256-GCM using a random IV.