Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
v0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
UmamiAppearance committed Sep 19, 2022
1 parent 455f295 commit d8e59e5
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 68 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ Added for the sake of completeness in terms of compatibility with [pythons hashl
##### ``BrowserSHAObj.new(algorithm, input)``
Asynchronously creates a new instance. Optionally takes the ``algorithm`` as the first parameter, also an optional ``input`` which can be provided as the second parameter, and gets passed to the [``update``](#updateinput-replacefalse) method.

##### ``BrowserSHAObj.baseEx``
A [BaseEx Instance](https://github.com/UmamiAppearance/BaseExJS#available-converterscharsets) for the possibility to manually convert (byte) representations.

#### Instance

Expand Down
45 changes: 25 additions & 20 deletions dist/BrowserSHAObj.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ class BaseTemplate {
/**
* [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -1428,7 +1428,7 @@ class Base1 extends BaseTemplate {
/**
* [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -1507,7 +1507,7 @@ class Base16 extends BaseTemplate {
/**
* [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -1606,7 +1606,7 @@ class Base32 extends BaseTemplate {
/**
* [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -1744,7 +1744,7 @@ class Base58 extends BaseTemplate{
/**
* [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -1831,7 +1831,7 @@ class Base64 extends BaseTemplate {
/**
* [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -1960,7 +1960,7 @@ class Base85 extends BaseTemplate {
/**
* [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0 AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke)
*/
Expand Down Expand Up @@ -2169,7 +2169,7 @@ class Base91 extends BaseTemplate {
/**
* [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -2279,7 +2279,7 @@ class ByteConverter {
/**
* [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -2443,7 +2443,7 @@ class LEB128 extends BaseTemplate {
/**
* [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -2504,7 +2504,7 @@ class SimpleBase extends BaseTemplate {
/**
* [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0 AND BSD-3-Clause (only regarding Base91, Copyright (c) 2000-2006 Joachim Henke)
*/
Expand Down Expand Up @@ -2562,12 +2562,13 @@ class BaseEx {
/**
* [BrowserSHAObj]{@link https://github.com/UmamiAppearance/BrowserSHAObj}
*
* @version 0.3.0
* @version 0.3.1
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/

const ALGORITHMS = ["SHA-1", "SHA-256", "SHA-384", "SHA-512"];
const BASE_EX = new BaseEx();


/**
Expand Down Expand Up @@ -2608,10 +2609,14 @@ class BrowserSHAObj {
throw new TypeError(`Available algorithms are: '${ALGORITHMS.join(", ")}'.`);
}

this.baseEx = new BaseEx();
this.#addConverters();
}

/**
* BaseEx instance.
*/
static baseEx = BASE_EX;


/**
* Static method to receive information about the
Expand Down Expand Up @@ -2715,7 +2720,7 @@ class BrowserSHAObj {
} else if (ArrayBuffer.isView(input)) {
input = new Uint8Array(input.buffer);
} else {
input = this.baseEx.byteConverter.encode(input, "uint8");
input = BASE_EX.byteConverter.encode(input, "uint8");
}

let finalInput;
Expand Down Expand Up @@ -2776,10 +2781,10 @@ class BrowserSHAObj {
const capitalize = str => str.charAt(0).toUpperCase().concat(str.slice(1));

this.hexdigest = () => this.#digest
? this.baseEx.base16.encode(this.#digest)
? BASE_EX.base16.encode(this.#digest)
: null;

const converters = Object.keys(this.baseEx);
const converters = Object.keys(BASE_EX);
this.basedigest = {
toSimpleBase: {}
};
Expand All @@ -2790,18 +2795,18 @@ class BrowserSHAObj {

for (const converter of converters) {
this.basedigest[`to${capitalize(converter)}`] = (...args) => this.#digest
? this.baseEx[converter].encode(this.#digest, ...args)
? BASE_EX[converter].encode(this.#digest, ...args)
: null;
}

for (const converter in this.baseEx.simpleBase) {
for (const converter in BASE_EX.simpleBase) {
this.basedigest.toSimpleBase[capitalize(converter)] = (...args) => this.#digest
? this.baseEx.simpleBase[converter].encode(this.#digest, ...args)
? BASE_EX.simpleBase[converter].encode(this.#digest, ...args)
: null;
}

this.basedigest.toBytes = (...args) => this.#digest
? this.baseEx.byteConverter.encode(this.#digest, ...args)
? BASE_EX.byteConverter.encode(this.#digest, ...args)
: null;
}
}
Expand Down
9 changes: 5 additions & 4 deletions dist/BrowserSHAObj.esm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 25 additions & 20 deletions dist/BrowserSHAObj.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ var BrowserSHAObj = (function () {
/**
* [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -1431,7 +1431,7 @@ var BrowserSHAObj = (function () {
/**
* [BaseEx|Base16 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/src/converters/base-16.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -1510,7 +1510,7 @@ var BrowserSHAObj = (function () {
/**
* [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -1609,7 +1609,7 @@ var BrowserSHAObj = (function () {
/**
* [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -1747,7 +1747,7 @@ var BrowserSHAObj = (function () {
/**
* [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -1834,7 +1834,7 @@ var BrowserSHAObj = (function () {
/**
* [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -1963,7 +1963,7 @@ var BrowserSHAObj = (function () {
/**
* [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0 AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke)
*/
Expand Down Expand Up @@ -2172,7 +2172,7 @@ var BrowserSHAObj = (function () {
/**
* [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -2282,7 +2282,7 @@ var BrowserSHAObj = (function () {
/**
* [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -2446,7 +2446,7 @@ var BrowserSHAObj = (function () {
/**
* [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/
Expand Down Expand Up @@ -2507,7 +2507,7 @@ var BrowserSHAObj = (function () {
/**
* [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS}
*
* @version 0.4.2
* @version 0.4.3
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0 AND BSD-3-Clause (only regarding Base91, Copyright (c) 2000-2006 Joachim Henke)
*/
Expand Down Expand Up @@ -2565,12 +2565,13 @@ var BrowserSHAObj = (function () {
/**
* [BrowserSHAObj]{@link https://github.com/UmamiAppearance/BrowserSHAObj}
*
* @version 0.3.0
* @version 0.3.1
* @author UmamiAppearance [mail@umamiappearance.eu]
* @license GPL-3.0
*/

const ALGORITHMS = ["SHA-1", "SHA-256", "SHA-384", "SHA-512"];
const BASE_EX = new BaseEx();


/**
Expand Down Expand Up @@ -2611,10 +2612,14 @@ var BrowserSHAObj = (function () {
throw new TypeError(`Available algorithms are: '${ALGORITHMS.join(", ")}'.`);
}

this.baseEx = new BaseEx();
this.#addConverters();
}

/**
* BaseEx instance.
*/
static baseEx = BASE_EX;


/**
* Static method to receive information about the
Expand Down Expand Up @@ -2718,7 +2723,7 @@ var BrowserSHAObj = (function () {
} else if (ArrayBuffer.isView(input)) {
input = new Uint8Array(input.buffer);
} else {
input = this.baseEx.byteConverter.encode(input, "uint8");
input = BASE_EX.byteConverter.encode(input, "uint8");
}

let finalInput;
Expand Down Expand Up @@ -2779,10 +2784,10 @@ var BrowserSHAObj = (function () {
const capitalize = str => str.charAt(0).toUpperCase().concat(str.slice(1));

this.hexdigest = () => this.#digest
? this.baseEx.base16.encode(this.#digest)
? BASE_EX.base16.encode(this.#digest)
: null;

const converters = Object.keys(this.baseEx);
const converters = Object.keys(BASE_EX);
this.basedigest = {
toSimpleBase: {}
};
Expand All @@ -2793,18 +2798,18 @@ var BrowserSHAObj = (function () {

for (const converter of converters) {
this.basedigest[`to${capitalize(converter)}`] = (...args) => this.#digest
? this.baseEx[converter].encode(this.#digest, ...args)
? BASE_EX[converter].encode(this.#digest, ...args)
: null;
}

for (const converter in this.baseEx.simpleBase) {
for (const converter in BASE_EX.simpleBase) {
this.basedigest.toSimpleBase[capitalize(converter)] = (...args) => this.#digest
? this.baseEx.simpleBase[converter].encode(this.#digest, ...args)
? BASE_EX.simpleBase[converter].encode(this.#digest, ...args)
: null;
}

this.basedigest.toBytes = (...args) => this.#digest
? this.baseEx.byteConverter.encode(this.#digest, ...args)
? BASE_EX.byteConverter.encode(this.#digest, ...args)
: null;
}
}
Expand Down
Loading

0 comments on commit d8e59e5

Please sign in to comment.