I'm using this command from this article to encrypt a file:

openssl enc -aes-256-cbc -in /etc/services -out services.dat -k MYPASSWORD

If MYPASSWORD is 40 characters in length, roughly how long would an attacker (with government-level resources) need to crack it?

I am a developer. I build web applications that spawn and despawn themselves with just a single shell script. The source code is in a public github repository. The application contains a file with a secret. ( cat ./secret would display AWS_SECRET_ACCESS_KEY) I obviously won't commit this file in plain text. I will use the above mentioned encrypting command to encrypt it, then check it in to github.


Basically, I don't want a rogue government to be able to find out what my AWS_SECRET_ACCESS_KEY is.

closed as primarily opinion-based by schroeder Mar 22 at 17:16

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    I'm not sure that we can answer every combination and permutation of crypto suite and key length along with potential computational power used to try and crack it. – schroeder Jul 19 '16 at 21:16
  • Comments are not for extended discussion; this conversation has been moved to chat. – Rory Alsop Jul 21 '16 at 10:12
  • Because you specifically ask about "how long in terms of months, days, years" and do not provide anything specific about what the resources are to break the encryption, it will be impossible to answer. – schroeder Mar 22 at 17:16

You shouldn't be using openssl to encrypt files. You should use gpg -c instead (which encrypts it with a symmetric cipher). Using openssl causes it to lack authentication, key strengthening, etc.

To answer the question though, a 40 character password (assuming it's entirely random chosen from a 95 character keyboard, since you gave no information about the entropy of your password) would have a keyspace of 9540. This is already more than the keyspace of AES256, so it will be exactly as secure as AES256 with a random password in CBC mode.

  • Actually, 95^40 ~ 2^256. (95^40 ~ 1.3e79, 2^256 ~ 1.2e77. Close enough.) And I'm not sure it's even meaningful to talk about a character set larger than the length of the password -- in the end, with a 40-character password, at most 40 distinct characters can be used. And 40^40 ~ 1.2e64 which is close to 2^192 ~ 6.3e57. – a CVn Jul 21 '16 at 12:01
  • 1
    @MichaelKjörling "I'm not sure it's even meaningful to talk about a character set larger than the length of the password" taking this logic to the extreme, a 1 character password would have 1^1=1 bit of entropy, therefore I would be able to guess it in 2 guesses every time. This is clearly wrong. If the 40 character password (pseudo)randomly samples the entire 95 character space then we should say it has roughly 95^40 bits. – Owen Jul 21 '16 at 14:52
  • when someone asks "how long" it would be nice to have an answer containing "months..." "days.." "years..." etc – american-ninja-warrior Jul 21 '16 at 15:45

AES is considered today to be the best symetric crypto algorithm to use. AES-256 is perfect, and with 40 characters, this is more than enough.

  • 4
    It depends on the characters. Ultimately a key is comprised of bits, and to conflate key length with password length is to ignore the particular weaknesses of passwords that could significantly affect the strength of the resultant key. – Xander Jul 21 '16 at 14:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.