This might be a noob question, but I couldn't find its answer anywhere online: why does an OpenSSL generated 256-bit AES key have 64 characters? The command I'm using to generate the key is:
$ openssl enc -aes-256-cbc -k secret -P -md sha1
salt=E2EE3D7072F8AAF4
key=C94A324B7221AA8A8760DA0717C80256EF4308EC6068B7144AA3BBA4A5F98007
iv =5C7CB13DBDA69B2C091E0D5E95943627
I thought I could just read the key string and base64 decode it to get a 256-bit AES key, but that didn't work because 64 characters turned into a 384-bit byte array after decoding.
/* read keyString from config... */
byte[] secretKey = Base64.getDecoder().decode(keyString);
Preconditions.checkArgument(secretKey.length == 32,
"Length of secretKey is %s-bit instead of 256-bit: %s",secretKey.length * 8, config.getSecretKey());
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey, "AES");
If I'm doing math correctly, a 256-bit key should be 41 characters in length after base64 encoding. Am I missing something obvious here?