تخطَّ إلى المحتوى

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).

require "openssl"
cipher = OpenSSL::Cipher.new("aes-256-ecb")
cipher.encrypt
cipher.key = key
encrypted = cipher.update(plaintext) + cipher.final
require "openssl"
cipher = OpenSSL::Cipher.new("aes-256-gcm")
cipher.encrypt
cipher.key = key
iv = cipher.random_iv
encrypted = cipher.update(plaintext) + cipher.final
tag = cipher.auth_tag

Replace ECB mode with AES-256-GCM using a random IV.