Encryption & Decryption

To secure the communication, besides whitelisting IP address, VNPAY implements encryption by using generated product key and secret key to encrypt your request parameters. Therefore, the encrypted data will be validated by VNPAY vice versa. If the keys are valid, then it will be considered genuine request or response. You may contact us to regenerate your encryption keys if needed.

NOTE: Please keep your secret key and product key confidentiality.

The VNPAY will generate 32-character length of secretKey and 16-character length of productKey.

secretKey: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

productKey: xxxxxxxxxxxxxxxx

Token Rules (token)

The calculation method of the token value: All fields (except the token field) are listed in the interface table, firstly sorted according to the lexicographical order (AZ) of the Key value, and then the format of Key=Value is formed, and the splicing with the & symbol This is:

Key1=Value1&Key2=Value2&…&KeyN=ValueN

Finally, the value of secret key is directly at the end (prefixes such as "&key=" are not required when splicing secret key), and finally the entire string is encoded with Md5-32 bits and converted to uppercase

For example the data request:
Key Value
a 22
z 88
c 33
b 44
For example the secret key:
abcabcabc
Build Token Step :
  1. Step 1. sorted according to the lexicographical order (AZ) of the Key value.
    Array ( [a] => 22 [b] => 44 [c] => 33 [z] => 88 )
  2. Step 2. use RFC 3986 to format of Key=Value is formed (without the empty value), and the splicing with the & symbol This is:
    a=22&b=44&c=33&z=88
  3. Step 3. the value of secret key is directly at the end (prefixes such as "&key=" are not required when splicing secret key)
    a=22&b=44&c=33&z=88abcabc
  4. Step 4. the entire string is encoded with Md5-32 bits
    091a2b90d675be3dcb9941131d99c57b
  5. Step 5. converted to uppercase
    091A2B90D675BE3DCB9941131D99C57B