Upload KYC
POST/v1/users/upload/kyc
Submit KYC documents and information for user verification
Encryption Requirements
The following parameters must be encrypted before sending:
firstNamelastNamepanNumberaadharNumber
Code for encryption
- JavaScript
- Python
- Java
- PHP
- Go
const crypto = require("crypto");
const encrypt = (plainText, password) => {
try {
const iv = crypto.randomBytes(16);
const key = crypto.createHash('sha256').update(password).digest('base64').substr(0, 32);
const cipher = crypto.createCipheriv('aes-256-cbc', key, iv);
let encrypted = cipher.update(plainText);
encrypted = Buffer.concat([encrypted, cipher.final()])
return iv.toString('hex') + ':' + encrypted.toString('hex');
} catch (error) {
console.log(error);
}
}
// To generate encryption
const sampleText = "apple";
const encryptedText = encrypt(sampleText, SECRET_KEY);
console.log(encryptedText);
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
import hashlib
import base64
def encrypt(plain_text, password):
try:
# Generate random IV
iv = get_random_bytes(16)
# Create key from password
key = hashlib.sha256(password.encode()).digest()[:32]
# Create cipher
cipher = AES.new(key, AES.MODE_CBC, iv)
# Pad plain text to be multiple of 16
pad_length = 16 - (len(plain_text) % 16)
padded_text = plain_text + (chr(pad_length) * pad_length)
# Encrypt
encrypted = cipher.encrypt(padded_text.encode())
# Return IV:encrypted format
return iv.hex() + ':' + encrypted.hex()
except Exception as error:
print(error)
# To generate encryption
sample_text = "apple"
encrypted_text = encrypt(sample_text, SECRET_KEY)
print(encrypted_text)
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.util.Base64;
public class Encryption {
public static String encrypt(String plainText, String password) {
try {
// Generate random IV
byte[] iv = new byte[16];
SecureRandom random = new SecureRandom();
random.nextBytes(iv);
IvParameterSpec ivSpec = new IvParameterSpec(iv);
// Create key from password
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] key = digest.digest(password.getBytes("UTF-8"));
SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
// Create cipher
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivSpec);
// Encrypt
byte[] encrypted = cipher.doFinal(plainText.getBytes("UTF-8"));
// Return IV:encrypted format
return bytesToHex(iv) + ":" + bytesToHex(encrypted);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private static String bytesToHex(byte[] bytes) {
StringBuilder result = new StringBuilder();
for (byte b : bytes) {
result.append(String.format("%02x", b));
}
return result.toString();
}
// To generate encryption
public static void main(String[] args) {
String sampleText = "apple";
String encryptedText = encrypt(sampleText, SECRET_KEY);
System.out.println(encryptedText);
}
}
<?php
function encrypt($plainText, $password) {
try {
// Generate random IV
$iv = openssl_random_pseudo_bytes(16);
// Create key from password
$key = substr(hash('sha256', $password, true), 0, 32);
// Encrypt
$encrypted = openssl_encrypt(
$plainText,
'aes-256-cbc',
$key,
OPENSSL_RAW_DATA,
$iv
);
// Return IV:encrypted format
return bin2hex($iv) . ':' . bin2hex($encrypted);
} catch (Exception $e) {
echo $e->getMessage();
return null;
}
}
// To generate encryption
$sampleText = "apple";
$encryptedText = encrypt($sampleText, SECRET_KEY);
echo $encryptedText;
?>
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/hex"
"fmt"
"log"
)
func encrypt(plainText string, password string) (string, error) {
// Generate random IV
iv := make([]byte, aes.BlockSize)
if _, err := rand.Read(iv); err != nil {
return "", err
}
// Create key from password
hash := sha256.Sum256([]byte(password))
key := hash[:32]
// Create cipher block
block, err := aes.NewCipher(key)
if err != nil {
return "", err
}
// Pad plaintext to be multiple of block size
plainTextBytes := []byte(plainText)
padding := aes.BlockSize - len(plainTextBytes)%aes.BlockSize
padText := make([]byte, len(plainTextBytes)+padding)
copy(padText, plainTextBytes)
for i := len(plainTextBytes); i < len(padText); i++ {
padText[i] = byte(padding)
}
// Encrypt
cipherText := make([]byte, len(padText))
mode := cipher.NewCBCEncrypter(block, iv)
mode.CryptBlocks(cipherText, padText)
// Return IV:encrypted format
return hex.EncodeToString(iv) + ":" + hex.EncodeToString(cipherText), nil
}
func main() {
// To generate encryption
sampleText := "apple"
secretKey := "YOUR_SECRET_KEY"
encryptedText, err := encrypt(sampleText, secretKey)
if err != nil {
log.Fatal(err)
}
fmt.Println(encryptedText)
}
Contact for SECRET_KEY
For access to SECRET_KEY for encryption, please contact support@onmeta.in
Request
Responses
- 200
- 400
- 401
Success
Bad Request
Unauthorized