@antigane/encryption
Version:
encryption with Lattice-based Cryptography
82 lines (58 loc) • 1.62 kB
Markdown
A TypeScript implementation of Lattice-based Cryptography for secure message encryption and decryption.
Install @antigane/encryption with npm
```bash
npm install @antigane/encryption
```
```typescript
import { createEncryptionService } from "@antigane/encryption";
```
```typescript
const encryptionService = createEncryptionService();
```
- m : total field Matrics (default. 128)
- n : total column Matrics (default. 64)
- q : Mod for math operation (default. 2053)
#### 3. Encryption
```typescript
const encryptedData = await encryptionService.encrypt(
"Hello, World!",
"password"
);
console.log("Encrypted Data:", encryptedData.data);
```
```typescript
const decryptedMessage = await encryptionService.decrypt(
encryptedData,
"password"
);
console.log("Decrypted Message:", decryptedMessage);
```
```typescript
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();
```

- [@ranaufalmuha](https://www.github.com/ranaufalmuha)