Added generate_mac method