Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverted a change to output encoding that broke special chars #9

Merged
merged 1 commit into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/age/age-encrypt-decrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ export async function decryptAge(
const hkdfKey = hkdf(sha256, fileKey, nonce, Buffer.from(hkdfBodyMessage, "utf8"), hkdfKeyLengthBytes)

const plaintext = STREAM.open(cipherText, hkdfKey)
return Buffer.from(plaintext).toString("binary")
return Buffer.from(plaintext).toString("utf8")
}
8 changes: 8 additions & 0 deletions test/age/age-encrypt-decrypt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,13 @@ describe("age", () => {
const result = await decryptAge(ciphertext)
expect(result).to.equal(bigPayload)
})

it("should correctly encrypt and decrypt special characters", async () => {
const someFrench = "ça a marché"
const ciphertext = await encryptAge(Buffer.from(someFrench))
const result = await decryptAge(ciphertext)

expect(result).to.equal(someFrench)
})
})
})
3 changes: 1 addition & 2 deletions test/drand/timelock-encrypter.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {expect} from "chai"
import {createTimelockEncrypter} from "../../src/drand/timelock-encrypter"
import {defaultClientInfo} from "../../src/drand/drand-client"
import {defaultClientInfo} from "../../src"
AnomalRoil marked this conversation as resolved.
Show resolved Hide resolved
import {MockDrandClient, validBeacon} from "./mock-drand-client"

describe("timelock encrypter", () => {

it("should throw an error if created with the genesis round", () => {
expect(() => createTimelockEncrypter(defaultClientInfo, new MockDrandClient(validBeacon), 0)).to.throw()
})
Expand Down