# CryptEncode Transforms the data from array with the specified method. ``` int  CryptEncode(    ENUM_CRYPT_METHOD   method,        // method    const uchar&        data[],        // source array    const uchar&        key[],         // key    uchar&              result[]       // destination array    ); ``` Parameters method [in]  Data transformation method. Can be one of the values of [ENUM_CRYPT_METHOD](/en/docs/constants/namedconstants/otherconstants#enum_crypt_method) enumeration. data[] [in]  Source array. key[] [in]  Key array. result[] [out]  Destination array. Return Value Amount of bytes in the destination array or 0 in case of error. To obtain information about the [error](/en/docs/constants/errorswarnings/errorcodes) call the [GetLastError()](/en/docs/check/getlasterror) function. Example: ``` //+------------------------------------------------------------------+ //| ArrayToHex                                                       | //+------------------------------------------------------------------+ string ArrayToHex(uchar &arr[],int count=-1)   {    string res=""; //--- check    if(count<0 || count>ArraySize(arr))       count=ArraySize(arr); //--- transform to HEX string    for(int i=0; i0)      {       //--- print encrypted data       PrintFormat("Encoded data: size=%d %s",res,ArrayToHex(dst));       //--- decode dst[] to src[]       res=CryptDecode(CRYPT_DES,dst,key,src);       //--- check error            if(res>0)         {          //--- print decoded data          PrintFormat("Decoded data: size=%d, string='%s'",ArraySize(src),CharArrayToString(src));         }       else          Print("Error in CryptDecode. Error code=",GetLastError());      }    else       Print("Error in CryptEncode. Error code=",GetLastError());   } ``` See also [Array Functions](/en/docs/array), [CryptDecode()](/en/docs/common/cryptdecode)