cryptography - How to use openssl to decrypt data encrypted by Java using AES -
i generating aes public key , iv (initialization vector) in java encrypt data. need decrypt using openssl
command. possible given store aes key , iv on disk?
following encryption logic
cipher cipher = cipher.getinstance("aes/cbc/pkcs5padding"); cipher.init(cipher.encrypt_mode, key, iv); byte[] stringbytes = pass.getbytes(); byte[] raw = cipher.dofinal(stringbytes); return base64.encodebase64string(raw);
generating aes key
secretkey secret_key = keygenerator.getinstance("aes").generatekey();
generating iv
securerandom random = new securerandom(); ivparameterspec iv = new ivparameterspec(random.generateseed(16));
i saving iv , aes key in file in disk unencrypted. how decrypt data using these 2 parameters using openssl
?
save them hexadecimals , use e.g.
-k `cat key.hex` -iv `cat iv.hex`
so that's using backticks instead of single quotation marks.
Comments
Post a Comment