-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
260 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
MONGO_DB_CONNECTION_STRING=mongodb://localhost:27017/mongo-encryption-query | ||
SALT='1234' | ||
HASH_KEYS='true' | ||
ENCRYPT_KEYS='true' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
MONGO_DB_CONNECTION_STRING=mongodb://localhost:27017/mongo-encryption-query | ||
SALT='1234' | ||
HASH_KEYS='true' | ||
ENCRYPT_KEYS='true' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import { PrivateKeyJwk } from "src/types"; | ||
import { generate, encrypt, decrypt } from "./cipher"; | ||
import { PublicKeyJwk, PrivateKeyJwk } from "../types"; | ||
|
||
describe("X25519", () => { | ||
it("encrypt and decrypt", async () => { | ||
const { publicKeyJwk, privateKeyJwk } = await generate(); | ||
const encoder = new TextEncoder(); | ||
const { privateKeyJwk } = await generate(); | ||
const message = { | ||
message: "It’s a dangerous business, Frodo, going out your door.", | ||
}; | ||
const jwe = await encrypt( | ||
Buffer.from(encoder.encode(JSON.stringify(message))), | ||
publicKeyJwk as PublicKeyJwk | ||
); | ||
const decryptedData = await decrypt(jwe, privateKeyJwk as PrivateKeyJwk); | ||
const jwe = encrypt(message, privateKeyJwk as PrivateKeyJwk); | ||
const jwe2 = encrypt(message, privateKeyJwk as PrivateKeyJwk); | ||
expect(jwe).toStrictEqual(jwe2); | ||
const decryptedData = decrypt(jwe, privateKeyJwk as PrivateKeyJwk); | ||
expect(decryptedData).toStrictEqual(message); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.