Re: Newbie question about AES encryption




Mark wrote:
I download some free code to create SHA1 hashes and AES encryption.
Using this code I created a program to encrypt strings by first
initializing the cipher with a SHA1 hash of the password, and then
encrypting the data with the password. It seems to work great by
encrypting a string such as "Encrypted String" and a password of
"password" to a resulting string of "J4lgK+NgpWWtXTyWmeNgow==". Now if
I try and decrypt ONLY PART of the encrypted string, say
"J4lgK+NgpWWtXT" with the password "password", part of the string is
decrypted successfully. I get a decrypted result of "Encrypted". This
seems odd. I would think by truncating part of the decrypted string, I
would get a bunch of garbage in the decrypted string.

Is this a cause for concern?

Further to Matthew's answer.

Say you have a 128 bit block encrypted with AES. If you change as
little as a single bit of that block, and then decrypt it, the result
will be totally random. It will not look anything like the original
plaintext block.

So, as I understand it, the full answer is as follows.

(1) Block ciphers (like AES) have "modes".

(2) If you encrypt in ECB mode, you can decrypt each block seperately
from any other block.

(3) Point (2) is generally considered to be a /dis/advantage - not an
advantage.

(4) If you encrypt in other modes, you can /not/ decrypt each block
seperately.

(5) In any case, regardless of mode, if you make /any change/ to the
bits within a single block, the decryption of that block will look like
random data. It will not look anything like the original plaintext
block.

I'm sure that someone else will jump in here, if any of that is wrong.

HTH,
TC (MVP MSAccess)
http://tc2.atspace.com

.



Relevant Pages

  • im still trying to get the grips of monoalphabetic substitution.
    ... Now one exercise is to create a keyword cipher. ... now I'm writing a program to do this, encrypt and decrypt. ... the key letter from the cipher letter and i would have my plaintext back, ...
    (sci.crypt)
  • Re: TEA for real-life embedded project?
    ... thought that in symetric ciphers these functions are more or less, well, ... AFAIK "symmetric" means only that the same key is used for encrypt ... encrypt & decrypt. ... RC4 is a symmetric cipher with the same algo for ...
    (sci.crypt)
  • Re: 2 Keys decrypts same message
    ... also encrypt Hwith the master key K_m, call this cipher as C2. ... C1 with the key Hto retrieve D. ... K_m can be used to decrypt C2 ...
    (sci.crypt)
  • Re: Problem with the Initialization Vector (IV)
    ... You can use your own key and the auto generated IV to encrypt. ... Now when you want to decrypt, you have the IV as part of the cipher text. ... > I'm using a Rijndael algorithm to encrypt a file, ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Encrypting/Decrypting Password from a Config File
    ... > I am looking for a way to encrypt a password in a configuration file ... > out in the open if someone were to look at the config file. ... > application would read encrypted password, decrypt the password back ... > // Create Encryption cipher ...
    (comp.lang.java.programmer)