Let's save a definition. Encode it with password/key and Get it again.
We will not use Get directly on directory but with combination of Get+StringToStream+Import.
Get works with streams since V9.0 so I see no reason not to go this way.
file = FileNameJoin[{$TemporaryDirectory, "def.m"}]; fileEnc = FileNameJoin[{$TemporaryDirectory, "def.enc"}]; DeleteFile /@ {file, fileEnc} //Quiet; (*just in case*) ClearAll @ f; f[x_] := x^2; Save[file, f]; password = "key"; Encode[file, fileEnc, password]; ClearAll @ f; stream = StringToStream @ Import[fileEnc, "Text"]; Get[stream , password]; Close[stream]; f[2] 4
Yeah, great... fortunately I've tested this with different password:
password = "kuba"; Encode[file, fileEnc, password]; ClearAll @ f; stream = StringToStream @ Import[fileEnc, "Text"]; Get[stream , password]; Close[stream]; f[2] Syntax::sntx: Invalid syntax in or before "f[x_] :eeev" (line 1 of "String["(*!1N!*)4mx. ^ w24yf0¡'h;1;U.#+"]") f[2]
From my observations it seems to be quite random.
p.s. using Get directly will work. but this is not what I'm after.
Reproduced on V9 V10 Win7


Get's documentation says nothing aboutGet[stream,password], this comprises the use of an undocumented feature and therefore may or may not do what one thinks it might. $\endgroup$