Questions tagged [ecb]

ECB (Electronic Code Book) is a degenerate mode of operation for block ciphers.

Electronic Codebook mode (ECB) is a mode of operation for block ciphers that involves dividing the message into blocks and encrypting each block independently.

ECB mode encryption

It is the simplest mode of operation, but is considered very weak. Identical plaintext blocks are encrypted into identical ciphertext blocks, which makes it easy for an attacker to circumvent its security. As such, it is not recommended to be used for any secure system. Instead, a secure mode such as Cipher-Block Chaining (CBC) or Counter (CTR) mode should be chosen.

Why ECB is not secure?

ECB is not semantically secure because identical blocks of plaintext will be encrypted to the same ciphertext block. This vulnerability helps the attacker to find out plaintext patterns.

141 questions
17
votes
4 answers

How to detect block cipher mode

How to detect if a message was crypt by CBC or ECB mode? I have made a function who encrypt in AES 128 CBC or ECB randomly, and I do hamming between clear text and cipher text, but seams not correlated to cipher mode. How can I detect the block…
Xantra
  • 223
  • 1
  • 3
  • 8
11
votes
5 answers

Golang AES ECB Encryption

Trying to emulate an algorithm in Go that is basically AES ECB Mode encryption. Here's what I have so far func Decrypt(data []byte) []byte { cipher, err := aes.NewCipher([]byte(KEY)) if err == nil { cipher.Decrypt(data,…
Jameo
  • 4,507
  • 8
  • 40
  • 66
9
votes
2 answers

ValueError: Data must be aligned to block boundary in ECB mode

I am trying aes 128 encryption in ECB mode with the following code. from Crypto.Cipher import AES key = 'abcdefghijklmnop' cipher = AES.new(key.encode('utf8'), AES.MODE_ECB) msg = cipher.encrypt(b'hello') print(msg.hex()) decipher =…
Jozf
  • 161
  • 2
  • 4
  • 9
7
votes
1 answer

Process a single AES-128-ECB block using C/C++ and openssl

I want to en- and decode a single 16 bytes block of data using AES-128-ECB cipher. First I did it via the openssl command line utility using the ASCII 16 characters string "a_key_simple_key" as the key and the ASCII 16 characters string…
ilya
  • 301
  • 1
  • 3
  • 7
7
votes
1 answer

PHP Encrypt/Decrypt with TripleDes, PKCS7, and ECB

I've got my encryption function working properly however I cannot figure out how to get the decrypt function to give proper output. Here is my encrypt function: function Encrypt($data, $secret) { //Generate a key from a hash $key =…
Brandon Green
  • 371
  • 1
  • 2
  • 9
6
votes
2 answers

Decrypting blowfish-ecb with nodejs crypto vs php's mcrypt

I'm trying to decode the following base64-encoded ciphertext in Node.js with the built-in crypto…
Adam M-W
  • 3,509
  • 9
  • 49
  • 69
5
votes
1 answer

cryptojs.decrypt returns empty result

I need to decrypt a hex message in JavaScript that has the exact same outcome as the code written in Java. However the Javascript version using CryptoJs returns an empty result Code in Java: private static void create() { byte[] sessionKey =…
5
votes
2 answers

Rails Encryption using AES, overcomplicated

I'm having trouble encrypting a value from a third party vendor I am using. Their instructions are as follows: 1) Convert the encryption password to a byte array. 2) Convert the value to be encrypted to a byte array. 3) The entire length of the…
Gabriel
  • 621
  • 7
  • 19
5
votes
1 answer

Encrypt binary data with aes-ecb on node.js

I try to do crypto on node.js but badly I fail to have the same result than online sites. I want to encrypt some binary data with a binary key. I use the tutorial on nodejs site but I have a different result from my reference data set. My reference…
Fanch
  • 141
  • 1
  • 1
  • 4
5
votes
3 answers

How to decrypt AES ECB using crypto-js

I am trying to send encrypted data from flash (client side) to javascript (running as jscript in asp) on the server side. There are several javascript Aes libraries, but they are virtually undocumented. I'm trying with crypto-js, but cant get the…
wingnut
  • 1,193
  • 2
  • 16
  • 25
4
votes
1 answer

CryptoJS javascript AES-128, ECB encrypt / decrypt

Goal: Simple CryptoJS example to encrypt, decrypt using AES-128, ECB, 0-padding. See below my runnable sample. Input text is "US0378331005-USD-US-en" which is encrypted (hopefully AES-128 with all the above) and then decrypted (which does not…
DavidDunham
  • 1,245
  • 1
  • 22
  • 44
4
votes
1 answer

Incorrect decrypted string implemented using AES/ECB/NoPadding and base 64 with crypto-js library

I am trying to encrypt/decrypt the below data using crypto-js and getting unexpected results. Library: https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js function encryptByAESECB(message, key) { var keyHex =…
4
votes
4 answers

How do I replicate Bluetooth's CCM scheme in .NET?

I'm working on a firmware update scheme that requires end-to-end encryption of a firmware image. The target device is a Bluetooth Low Energy chip, with hardware support for the cryptography specified in Blueooth Spec, AES-CCM. We want to leverage…
Sarkreth
  • 290
  • 2
  • 10
4
votes
1 answer

DES ECB encryption with PHP

https://www.tools4noobs.com/online_tools/encrypt/ gives "a67a318c98a0307502ba81caade2f3a9" as a DES ECB result for the key "1234567890abcdef" and payload "encrypt this". The PHP code echo bin2hex(mcrypt_encrypt( MCRYPT_DES, …
haba713
  • 2,465
  • 1
  • 24
  • 45
4
votes
3 answers

Python Blowfish Encryption

I am struggling due to my incomplete knowledge of Java to convert this encryption code to Python code. The two should have the exact same results. Help would be greatly appreciated. Java Function import javax.crypto.Cipher; import…
Hunter Larco
  • 785
  • 5
  • 17
1
2 3
9 10