Skip to main content
Glama
larksuite

Feishu/Lark OpenAPI MCP

Official
by larksuite
encryption.ts1.35 kB
import crypto from 'crypto'; import { AUTH_CONFIG } from '../config'; import { logger } from '../../utils/logger'; export class EncryptionUtil { private aesKey: string; constructor(aesKey: string) { this.aesKey = aesKey; } encrypt(data: string): string { const iv = crypto.randomBytes(AUTH_CONFIG.ENCRYPTION.IV_LENGTH); const key = Buffer.from(this.aesKey, 'hex'); const cipher = crypto.createCipheriv(AUTH_CONFIG.ENCRYPTION.ALGORITHM, key, iv); let encrypted = cipher.update(data, 'utf8', 'hex'); encrypted += cipher.final('hex'); return iv.toString('hex') + ':' + encrypted; } decrypt(encryptedData: string): string { const parts = encryptedData.split(':'); if (parts.length !== 2) { logger.error(`[EncryptionUtil] decrypt: Invalid encrypted data format`); throw new Error('Invalid encrypted data format'); } const iv = Buffer.from(parts[0], 'hex'); const encrypted = parts[1]; const key = Buffer.from(this.aesKey, 'hex'); const decipher = crypto.createDecipheriv(AUTH_CONFIG.ENCRYPTION.ALGORITHM, key, iv); let decrypted = decipher.update(encrypted, 'hex', 'utf8'); decrypted += decipher.final('utf8'); return decrypted; } static generateKey(): string { return crypto.randomBytes(AUTH_CONFIG.ENCRYPTION.KEY_LENGTH).toString('hex'); } }

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/larksuite/lark-openapi-mcp'

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