\makeatletter
\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{etoolbox}
\let\Gin@userpassword\@empty
\define@key{Gin}{userpassword}{%
\def\Gin@userpassword{#1}}
\patchcmd{\Gread@@pdftex}{%
\ifx\Gin@page\@empty\else page \Gin@page\fi}{%
\ifx\Gin@page\@empty\else page \Gin@page\fi
\ifx\Gin@userpassword\@empty\else userpassword{\Gin@userpassword}\fi}{}{}
\patchcmd{\Gread@@pdftex}{%
\@ifundefined{#1 image\Gin@attr@hash}}{%
\check@userpassword{#1}{\Gin@userpassword}%
\@ifundefined{#1 image\Gin@attr@hash}}{}{}