TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Simple and Terrifying Encryption Story

16 pointsby donnemartinover 8 years ago

2 comments

vms20591over 8 years ago
From the post,<p>If you pass a wrong key, aes gem raises an error:<p>decrypted = AES.decrypt(encrypted, &quot;Some other password&quot;) #=&gt; aes.rb:76:in `final&#x27;: bad decrypt (OpenSSL::Cipher::CipherError)<p>I have a small doubt with the above statement, how come the following didn&#x27;t raise any error?<p>encrypted = AES.encrypt(&quot;Super secret message&quot;, &quot;password&quot;) decrypted = AES.decrypt(encrypted, &quot;totally wrong password&quot;) decrypted #=&gt; Super secret message<p>In the above, the enc key used was &quot;password&quot; and the dec key used was &quot;totally wrong password&quot;. The call to the hex function should have returned &quot;0&quot; for the character pairs in the dec key which should&#x27;ve been the same result for enc key. Why didn&#x27;t the library raise any error but instead decrypted correctly?<p>PS: I haven&#x27;t tried it yet and would try to check it out. Just wanted to know if there is already a reason for it.
e1ghtSpaceover 8 years ago
How does this go unnoticed to the developer?