Modified to use crypto object