import { createSealClient } from './seal-client';
async function basicExample() {
const { sealClient } = await createSealClient();
const sensitiveData = "这是我的秘密消息!";
const recipientAddress = "0x742d35cc6d4c0c08c0f9bf3c9b2b6c64b3b4f5c6d7e8f9a0b1c2d3e4f5a6b7c8";
try {
const encryptedData = await sealClient.encrypt({
data: Buffer.from(sensitiveData, 'utf-8'),
recipientId: recipientAddress,
metadata: {
contentType: 'text/plain',
timestamp: Date.now()
}
});
console.log('加密数据:', {
ciphertext: encryptedData.ciphertext.toString('base64'),
encryptionId: encryptedData.encryptionId
});
const decryptedData = await sealClient.decrypt({
ciphertext: encryptedData.ciphertext,
encryptionId: encryptedData.encryptionId,
recipientId: recipientAddress
});
console.log('解密数据:', decryptedData.toString('utf-8'));
} catch (error) {
console.error('