Skip to content

Commit

Permalink
Reverted a change to output encoding that broke special chars (#9)
Browse files Browse the repository at this point in the history
the previous commit that added the binary encoding said it was
necessary for correct enc/dec, but none of the tests failed
when removed and I suspect it was added before we sorted the
chunking issues
  • Loading branch information
CluEleSsUK authored Sep 9, 2022
1 parent 4eb726a commit 920e5dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
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"
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

0 comments on commit 920e5dd

Please sign in to comment.