Try this code
#include <Crypt.au3>
Ini_Write("Password","Filename.ini","Section","Key","Value")
$Value = Ini_Read("Password","Filename.ini","Section","Key")
if Not @error Then _
MsgBox(0,"MSG",$Value)
Func Ini_Write($Password,$Filename,$Section,$Key,$Value)
_Crypt_Startup()
if @error Then Return SetError(1,@error,False)
$hKey =_Crypt_DeriveKey($Password,$CALG_RC4)
if @error Then Return SetError(2,@error,False)
$ByteStruct = DllStructCreate("BYTE[" & StringLen($Value) & "]")
DllStructSetData($ByteStruct,1,$Value)
$StrByte = String(DllStructGetData($ByteStruct,1))
$EncryptedValue = _Crypt_EncryptData($StrByte,$hKey,$CALG_USERKEY)
if @error Then Return SetError(3,@error,False)
IniWrite($Filename,$Section,$Key,$EncryptedValue)
if @error Then Return SetError(4,@error,False)
_Crypt_DestroyKey($hKey)
_Crypt_Shutdown()
Return SetError(0,0,True)
EndFunc
Func Ini_Read($Password,$Filename,$Section,$Key,$Default = "NotFound")
$EncryptedValue = IniRead($Filename,$Section,$Key,$Default)
if $EncryptedValue == $Default Then Return SetError(1,0,$Default)
_Crypt_Startup()
if @error Then Return SetError(2,@error,$Default)
$hKey =_Crypt_DeriveKey($Password,$CALG_RC4)
if @error Then Return SetError(3,@error,$Default)
$Binary = _Crypt_DecryptData($EncryptedValue,$hKey,$CALG_USERKEY)
if @error Then Return SetError(4,@error,$Default)
$StrByte = BinaryToString($Binary)
if @error Then Return SetError(5,@error,$Default)
$ByteStruct = DllStructCreate("BYTE[" & BinaryLen($StrByte) & "]")
DllStructSetData($ByteStruct,1,$StrByte)
$CharStruct = _
DllStructCreate("CHAR[" & DllStructGetSize($ByteStruct) & "]",DllStructGetPtr($ByteStruct))
_Crypt_DestroyKey($hKey)
_Crypt_Shutdown()
Return SetError(0,0,DllStructGetData($CharStruct,1))
EndFunc