added random IV generation and handling to crypto functions