Skip to main content
Glama
encryption.cjs1.04 kB
/** * RSA encryption module using pidCrypt * IG requires a specific RSA encryption format that pidCrypt provides */ const pidCrypt = require('pidcrypt'); require('pidcrypt/rsa'); require('pidcrypt/asn1'); const pidCryptUtil = require('pidcrypt/pidcrypt_util'); /** * Encrypts password using IG's required RSA format * @param {string} password - Plain text password * @param {string} encryptionKey - Base64 encoded public key from IG * @param {string|number} timestamp - Timestamp from IG * @returns {string} Base64 encoded encrypted password */ function encryptPassword(password, encryptionKey, timestamp) { const rsa = new pidCrypt.RSA(); const decodedKey = pidCryptUtil.decodeBase64(encryptionKey); const asn = pidCrypt.ASN1.decode(pidCryptUtil.toByteArray(decodedKey)); const tree = asn.toHexTree(); rsa.setPublicKeyFromASN(tree); const result = pidCryptUtil.encodeBase64( pidCryptUtil.convertFromHex(rsa.encrypt(`${password}|${timestamp}`)) ); return result; } module.exports = { encryptPassword };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kea0811/ig-trading-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server