Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
How can I identify a double AES encrypted cipherText

I mistakenly encrypted some of my values in the db twice. Is there a way to identify double encrypted ciphertext.

    var ciphertext = cryptoJS.AES.encrypt(plainText, secretKey).toString();
    var ciphertext2 = cryptoJS.AES.encrypt(ciphertext, secretKey).toString();
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There are two ways to do this, and both are high certainty but have drawbacks.

First of all, if you don't give an well formatted key / IV then CryptoJS will use an OpenSSL key derivation mechanism to derive the key and IV. If you use toString() it will then stringify the result. This of course adds some overhead, so if you know the original size of the message then you can simply try and detect double encryption by the increase of the size.

Second, you can decrypt once, and then look for the format that toString generates. This is a base 64 string which, after decoding, should contain Salted__ in ASCII (followed by the salt and then the AES-CBC / PKCS#7 ciphertext). As your plaintext is unlikely to start with Salted__ this should be enough of a distinguisher. So your decrypt routine could run in a loop until the Salted__ string isn't found anymore.

Otherwise: AES encrypted ciphertext is fully randomized, so you cannot see anything looking at the ciphertext itself. In this case however, the ciphertext is part of a proprietary protocol, which opens up some possiblities.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!