Skip to main content

Credit card encryption

Multicart Solution Inc.Api usageLess than 1 minute

Encryption PAN and CVV fields

Used The RSA-OAEP public-key encryption system is specified in RFC 3447

This type of encryption is used for both fields

TypeScrypt example:

const importRsaKey() = async(binaryDer: ArrayBuffer): Promise<CryptoKey> => {
        const result = await window.crypto.subtle.importKey(
            'spki',
            binaryDer,
            {
                name: 'RSA-OAEP',
                hash: 'SHA-256',
            },
            true,
            ['encrypt']
        );

        return result;
    }

const encrypt = async (value: string; publicKey: CryptoKey): Promise<string> => {
	const enc = new TextEncoder();
	const bytes = enc.encode(value);

	const cipher = await window.crypto.subtle.encrypt(
		{
			name: 'RSA-OAEP',
		},
		publicKey,
		bytes);

	return arrayBufferToBase64(cipher);
};