Trading APIs

Authorization

All API requests are initiated post successful Customer login. Customer is required to login everytime a session is inactive for more than 30 Minutes.

For Customer Login, the user's Email ID, Password and DOB need to be encrypted and sent.

The encryption logic is as follows: Language used : VB.NET
.Net Framework : 4.7.1

While encryption follow below steps:

Step 1 : Converting plain-text UserID to encoding2.GetBytes - Consider this as input 'data()' MyKey is the Encryption Key assigned at the time of registration.

Step 2: Passing both the values to below mentioned Encryption function, in return it will give values in bytes Public Shared Function Encryption(ByVal data() As Byte, ByVal MyKey As String, ByRef EncData() As Byte) As Int32
Try
'Comment for below mention line -- Convert MyKey ie., 64 character Key to Bytes of length : 48
Dim _key() As Byte = Convert.FromBase64String(MyKey)
'Comment for below mention line -- For more security purpose, again generating Bytes of below mentioned comma seperated values of length : 16
Dim _iv() As Byte = {83, 71, 26, 58, 54, 35, 22, 11, 83, 71, 26, 58, 54, 35, 22, 11}
'Comment for below mention line -- Passing both above generated bytes values to below mention Encry System.Security.Cryptography.Rfc2898DeriveBytes function
Dim keyBuilder As Rfc2898DeriveBytes = New Rfc2898DeriveBytes(MyKey, _iv)
'Comment for below mention line -- String to a filestream, used a memorystream
Dim ms As New MemoryStream()
'Comment for below mention line -- Creating object of System.Security.Cryptography.RijndaelManaged
Dim aes As New RijndaelManaged()
'Comment for below mention line -- Setting Advanced Encryption Standard KeySize
aes.KeySize = 256
'Comment for below mention line -- A byte array filled with pseudo-random key bytes.
aes.IV = keyBuilder.GetBytes(CType(aes.BlockSize / 8, Integer))
aes.Key = keyBuilder.GetBytes(CType(aes.KeySize / 8, Integer))
'Initializes a new instance of the System.Security.Cryptography.CryptoStream class
Dim cs As New CryptoStream(ms, aes.CreateEncryptor, CryptoStreamMode.Write)
'Comment for below mention line -- Writes a sequence of bytes to the current System.Security.Cryptography.CryptoStream
cs.Write(data, 0, data.Length)
'Comment for below mention line -- clears the buffer.
cs.FlushFinalBlock()
'The byte array from which this stream was created
EncData = ms.GetBuffer()
ReDim Preserve EncData(ms.Position - 1)
Return ms.Position
Catch ex As Exception
Throw ex
End Try
End Function

Step 3 : Converting the values received from above Step 2 with ToBase64String. Example :
Values to pass for Step 1 :
Input :
data() - mkjhytfd48j
MyKey - 58xZ4dP3K762WtpDVt5EjqnNdfTZD844s8CAW5gGy9w7WMhuVtUPJ7xU2EMCrFQk
Output :
It will generate 16 bytes value
Input :
Values to pass for Step 2 :
Convert above generated bytes value to ToBase64String
Output :
XB+RbZ6RIymFbWFmjoTf5w==