Files
zCode-CLI-X/~/.npm-cache/hono@4.12.9@@@1/dist/utils/crypto.js
admin 875c7f9b91 feat: Complete zCode CLI X with Telegram bot integration
- Add full Telegram bot functionality with Z.AI API integration
- Implement 4 tools: Bash, FileEdit, WebSearch, Git
- Add 3 agents: Code Reviewer, Architect, DevOps Engineer
- Add 6 skills for common coding tasks
- Add systemd service file for 24/7 operation
- Add nginx configuration for HTTPS webhook
- Add comprehensive documentation
- Implement WebSocket server for real-time updates
- Add logging system with Winston
- Add environment validation

🤖 zCode CLI X - Agentic coder with Z.AI + Telegram integration
2026-05-05 09:01:26 +00:00

45 lines
1.1 KiB
JavaScript

// src/utils/crypto.ts
var sha256 = async (data) => {
const algorithm = { name: "SHA-256", alias: "sha256" };
const hash = await createHash(data, algorithm);
return hash;
};
var sha1 = async (data) => {
const algorithm = { name: "SHA-1", alias: "sha1" };
const hash = await createHash(data, algorithm);
return hash;
};
var md5 = async (data) => {
const algorithm = { name: "MD5", alias: "md5" };
const hash = await createHash(data, algorithm);
return hash;
};
var createHash = async (data, algorithm) => {
let sourceBuffer;
if (ArrayBuffer.isView(data) || data instanceof ArrayBuffer) {
sourceBuffer = data;
} else {
if (typeof data === "object") {
data = JSON.stringify(data);
}
sourceBuffer = new TextEncoder().encode(String(data));
}
if (crypto && crypto.subtle) {
const buffer = await crypto.subtle.digest(
{
name: algorithm.name
},
sourceBuffer
);
const hash = Array.prototype.map.call(new Uint8Array(buffer), (x) => ("00" + x.toString(16)).slice(-2)).join("");
return hash;
}
return null;
};
export {
createHash,
md5,
sha1,
sha256
};