Skip to content

Commit

Permalink
Rename exported identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Jan 31, 2024
1 parent 615ea90 commit bd3f150
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions crates/wasm/CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ project adheres to https://semver.org/[Semantic Versioning].
=== Changed

* Change `Params::new` to `constructor` ({pull-request-url}/252[#252])
* Rename exported identifiers ({pull-request-url}/256[#256])

== {compare-url}/abcrypt-wasm-v0.1.0\...abcrypt-wasm-v0.1.1[0.1.1] - 2024-01-28

Expand Down
2 changes: 1 addition & 1 deletion crates/wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const data = new TextEncoder().encode("Hello, world!\n");
const passphrase = new TextEncoder().encode("passphrase");

// Encrypt `data` using `passphrase`.
const ciphertext = abcrypt.encrypt_with_params(data, passphrase, 32, 3, 4);
const ciphertext = abcrypt.encryptWithParams(data, passphrase, 32, 3, 4);
assert.assertNotEquals(ciphertext, data);

// And decrypt it back.
Expand Down
5 changes: 2 additions & 3 deletions crates/wasm/examples/decrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ const { args, options } = await new command.Command()

const ciphertext = Deno.readFileSync(args[0]);

const passphrase = new TextEncoder().encode(
cli.promptSecret("Enter passphrase: ")!,
);
const passphrase = new TextEncoder()
.encode(cli.promptSecret("Enter passphrase: ")!);
const plaintext = abcrypt.decrypt(ciphertext, passphrase);

if (options.output === undefined) {
Expand Down
7 changes: 3 additions & 4 deletions crates/wasm/examples/encrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ const { args, options } = await new command.Command()

const plaintext = Deno.readFileSync(args[0]);

const passphrase = new TextEncoder().encode(
cli.promptSecret("Enter passphrase: ")!,
);
const ciphertext = abcrypt.encrypt_with_params(
const passphrase = new TextEncoder()
.encode(cli.promptSecret("Enter passphrase: ")!);
const ciphertext = abcrypt.encryptWithParams(
plaintext,
passphrase,
options.memorySize,
Expand Down
2 changes: 1 addition & 1 deletion crates/wasm/examples/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ const ciphertext = args[0] === undefined

const params = new abcrypt.Params(ciphertext);
console.log(
`Parameters used: m_cost = ${params.m_cost}; t_cost = ${params.t_cost}; p_cost = ${params.p_cost};`,
`Parameters used: m_cost = ${params.mCost}; t_cost = ${params.tCost}; p_cost = ${params.pCost};`,
);
2 changes: 1 addition & 1 deletion crates/wasm/src/encrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn encrypt(plaintext: &[u8], passphrase: &[u8]) -> Result<Vec<u8>, JsError>
/// # Errors
///
/// Returns [`Err`] if the Argon2 context is invalid.
#[wasm_bindgen]
#[wasm_bindgen(js_name = encryptWithParams)]
pub fn encrypt_with_params(
plaintext: &[u8],
passphrase: &[u8],
Expand Down
4 changes: 2 additions & 2 deletions crates/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub use crate::{
/// Returns the number of bytes of the header.
#[must_use]
#[inline]
#[wasm_bindgen]
#[wasm_bindgen(js_name = headerSize)]
pub fn header_size() -> usize {
abcrypt::HEADER_SIZE
}
Expand All @@ -38,7 +38,7 @@ pub fn header_size() -> usize {
/// ciphertext.
#[must_use]
#[inline]
#[wasm_bindgen]
#[wasm_bindgen(js_name = tagSize)]
pub fn tag_size() -> usize {
abcrypt::TAG_SIZE
}
Expand Down
6 changes: 3 additions & 3 deletions crates/wasm/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Params {
/// Gets memory size in KiB.
#[must_use]
#[inline]
#[wasm_bindgen(getter)]
#[wasm_bindgen(js_name = mCost, getter)]
pub fn m_cost(&self) -> u32 {
self.0.m_cost()
}
Expand All @@ -44,7 +44,7 @@ impl Params {
/// Gets number of iterations.
#[must_use]
#[inline]
#[wasm_bindgen(getter)]
#[wasm_bindgen(js_name = tCost, getter)]
pub fn t_cost(&self) -> u32 {
self.0.t_cost()
}
Expand All @@ -53,7 +53,7 @@ impl Params {
/// Gets degree of parallelism.
#[must_use]
#[inline]
#[wasm_bindgen(getter)]
#[wasm_bindgen(js_name = pCost, getter)]
pub fn p_cost(&self) -> u32 {
self.0.p_cost()
}
Expand Down
2 changes: 1 addition & 1 deletion docs/book/modules/wasm/pages/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const data = new TextEncoder().encode("Hello, world!\n");
const passphrase = new TextEncoder().encode("passphrase");
// Encrypt `data` using `passphrase`.
const ciphertext = abcrypt.encrypt_with_params(data, passphrase, 32, 3, 4);
const ciphertext = abcrypt.encryptWithParams(data, passphrase, 32, 3, 4);
assert.assertNotEquals(ciphertext, data);
// And decrypt it back.
Expand Down

0 comments on commit bd3f150

Please sign in to comment.