0.1.5 • Published 10 months ago
@antigane/encryption v0.1.5
Antigane Encryption
A TypeScript implementation of Lattice-based Cryptography for secure message encryption and decryption.
Installation
Install @antigane/encryption with npm
npm install @antigane/encryptionUsage
1. Import Package
import { createEncryptionService } from "@antigane/encryption";2. Create Instance Encryption
const encryptionService = createEncryptionService();- m : total field Matrics (default. 128)
- n : total column Matrics (default. 64)
- q : Mod for math operation (default. 2053)
3. Encryption
const encryptedData = await encryptionService.encrypt(
"Hello, World!",
"password"
);
console.log("Encrypted Data:", encryptedData.data);4. Decryption
const decryptedMessage = await encryptionService.decrypt(
encryptedData,
"password"
);
console.log("Decrypted Message:", decryptedMessage);Example
import { createEncryptionService } from "@antigane/encryption";
async function main() {
const encryptionService = createEncryptionService();
// Enkripsi pesan
const encryptedData = await encryptionService.encrypt(
"Hello, World!",
"password"
);
console.log("Encrypted Data:", encryptedData.data);
// Dekripsi pesan
const decryptedMessage = await encryptionService.decrypt(
encryptedData,
"password"
);
console.log("Decrypted Message:", decryptedMessage);
}
main();