action:
salt = "akQPbsRjMTNSnK99"
inner_code = "4f5cb4c16fcc446946846b27a2f22239"
encrypted_str = AESCrypt.encrypt(inner_code, salt)
加密成功,获取加密后的明文:
fAXjMZDEsHzVK4XhDpLrwqqs9gIw4qaRYB6PQBYdpUEBtwnvD6 /hxcVzN4Dddfz
可是在执行解密的时候:
salt = "akQPbsRjMTNSnK99"
st = params[:st] #fAXjMZDEsHzVK4XhDpLrwqqs9gIw4qaRYB6PQBYdpUEBtwnvD6 /hxcVzN4Dddfz
inner_code = AESCrypt.decrypt(st, salt)
抛出异常:
Processing by GoodsController#sg as HTML
Parameters: {"st"=>"fAXjMZDEsHzVK4XhDpLrwqqs9gIw4qaRYB6PQBYdpUEBtwnvD6 /hxcVzN4Dddfz"}
Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.0ms)
OpenSSL::Cipher::CipherError (wrong final block length):
不是每次都会发生,有的明文可以解密成功,有的则会出发这个异常. 这是为何?