@vvlad1973/crypto 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.hintrc +15 -0
- package/.vscode/launch.json +20 -0
- package/CLAUDE.md +90 -0
- package/LICENSE +19 -0
- package/README.md +253 -0
- package/dist/__tests__/crypto.test.d.ts +1 -0
- package/dist/__tests__/crypto.test.js +181 -0
- package/dist/crypto.d.ts +59 -0
- package/dist/crypto.js +89 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +78 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1633 -0
- package/docs/classes/Crypto.html +20 -0
- package/docs/functions/isCrypto.html +4 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +43 -0
- package/docs/interfaces/CryptoOptions.html +15 -0
- package/docs/modules.html +1 -0
- package/package.json +44 -0
- package/src/__tests__/crypto.test.ts +238 -0
- package/src/crypto.ts +141 -0
- package/src/index.ts +2 -0
- package/tsconfig.json +21 -0
- package/typedoc.json +18 -0
- package/vitest.config.ts +36 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Crypto | @vvlad1973/crypto - v2.1.0</title><meta name="description" content="Documentation for @vvlad1973/crypto"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@vvlad1973/crypto - v2.1.0</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">Crypto</a></li></ul><h1>Class Crypto</h1></div><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><p>Class representing a cryptographic utility for encrypting and decrypting text.</p>
|
|
2
|
+
</div><div class="tsd-comment tsd-typography"><div class="tsd-tag-param"><h4 class="tsd-anchor-link" id="param-passwordoroptions">Param: passwordOrOptions<a href="#param-passwordoroptions" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>The password used for key derivation or an options object.</p>
|
|
3
|
+
</div><div class="tsd-tag-param"><h4 class="tsd-anchor-link" id="param-salt">Param: salt<a href="#param-salt" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>The salt used for key derivation.</p>
|
|
4
|
+
</div><div class="tsd-tag-param"><h4 class="tsd-anchor-link" id="param-algorithm">Param: algorithm<a href="#param-algorithm" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>The hash algorithm to use for key derivation.</p>
|
|
5
|
+
</div><div class="tsd-tag-param"><h4 class="tsd-anchor-link" id="param-iterations">Param: iterations<a href="#param-iterations" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>The number of iterations to use for key derivation.</p>
|
|
6
|
+
</div><div class="tsd-tag-param"><h4 class="tsd-anchor-link" id="param-keylength">Param: keyLength<a href="#param-keylength" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>The length of the derived key in bytes.</p>
|
|
7
|
+
</div><div class="tsd-tag-param"><h4 class="tsd-anchor-link" id="param-iv">Param: iv<a href="#param-iv" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>The initialization vector for the AES encryption.</p>
|
|
8
|
+
</div></div></section><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vvlad1973/vvlad1973-crypto/blob/c6e7262c1966961460db0e1915a90ab637f083c8/src/crypto.ts#L51">crypto.ts:51</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h5 class="tsd-index-heading uppercase">Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a>
|
|
9
|
+
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Methods</h3><div class="tsd-index-list"><a href="#encrypt" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>encrypt</span></a>
|
|
10
|
+
<a href="#decrypt" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>decrypt</span></a>
|
|
11
|
+
<a href="#getuuid" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>get<wbr/>UUID</span></a>
|
|
12
|
+
</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Constructors</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="constructor"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="constructorcrypto"><span class="tsd-signature-keyword">new</span> <span class="tsd-kind-constructor-signature">Crypto</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">password</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">salt</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">algorithm</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">iterations</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">keyLength</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">iv</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">Buffer</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Crypto</a><a href="#constructorcrypto" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">password</span>: <span class="tsd-signature-type">string</span></span></li><li><span><span class="tsd-kind-parameter">salt</span>: <span class="tsd-signature-type">string</span></span></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">algorithm</span>: <span class="tsd-signature-type">string</span></span></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">iterations</span>: <span class="tsd-signature-type">number</span></span></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">keyLength</span>: <span class="tsd-signature-type">number</span></span></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">iv</span>: <span class="tsd-signature-type">number</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">Buffer</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Crypto</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vvlad1973/vvlad1973-crypto/blob/c6e7262c1966961460db0e1915a90ab637f083c8/src/crypto.ts#L55">crypto.ts:55</a></li></ul></aside></div></li><li class=""><div class="tsd-signature tsd-anchor-link" id="constructorcrypto-1"><span class="tsd-signature-keyword">new</span> <span class="tsd-kind-constructor-signature">Crypto</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">:</span> <a href="../interfaces/CryptoOptions.html" class="tsd-signature-type tsd-kind-interface">CryptoOptions</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Crypto</a><a href="#constructorcrypto-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <a href="../interfaces/CryptoOptions.html" class="tsd-signature-type tsd-kind-interface">CryptoOptions</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Crypto</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vvlad1973/vvlad1973-crypto/blob/c6e7262c1966961460db0e1915a90ab637f083c8/src/crypto.ts#L63">crypto.ts:63</a></li></ul></aside></div></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Methods</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="encrypt"><span>encrypt</span><a href="#encrypt" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="encrypt-1"><span class="tsd-kind-call-signature">encrypt</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">text</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><a href="#encrypt-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Encrypt a text string.</p>
|
|
13
|
+
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">text</span>: <span class="tsd-signature-type">string</span></span><div class="tsd-comment tsd-typography"><p>The plain text to encrypt.</p>
|
|
14
|
+
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4><p>The encrypted text as a hex string.</p>
|
|
15
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vvlad1973/vvlad1973-crypto/blob/c6e7262c1966961460db0e1915a90ab637f083c8/src/crypto.ts#L108">crypto.ts:108</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="decrypt"><span>decrypt</span><a href="#decrypt" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="decrypt-1"><span class="tsd-kind-call-signature">decrypt</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">text</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><a href="#decrypt-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Decrypt an encrypted text string.</p>
|
|
16
|
+
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">text</span>: <span class="tsd-signature-type">string</span></span><div class="tsd-comment tsd-typography"><p>The encrypted text as a hex string.</p>
|
|
17
|
+
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4><p>The decrypted plain text.</p>
|
|
18
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vvlad1973/vvlad1973-crypto/blob/c6e7262c1966961460db0e1915a90ab637f083c8/src/crypto.ts#L122">crypto.ts:122</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="getuuid"><code class="tsd-tag">Static</code><span>get<wbr/>UUID</span><a href="#getuuid" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="getuuid-1"><span class="tsd-kind-call-signature">getUUID</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><a href="#getuuid-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns a UUID ver.4 string.</p>
|
|
19
|
+
</div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4><p>UUID ver.4 string.</p>
|
|
20
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vvlad1973/vvlad1973-crypto/blob/c6e7262c1966961460db0e1915a90ab637f083c8/src/crypto.ts#L136">crypto.ts:136</a></li></ul></aside></div></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#encrypt"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>encrypt</span></a><a href="#decrypt"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>decrypt</span></a><a href="#getuuid"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>get<wbr/>UUID</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">@vvlad1973/crypto - v2.1.0</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>isCrypto | @vvlad1973/crypto - v2.1.0</title><meta name="description" content="Documentation for @vvlad1973/crypto"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@vvlad1973/crypto - v2.1.0</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">isCrypto</a></li></ul><h1>Function isCrypto</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="iscrypto"><span class="tsd-kind-call-signature">isCrypto</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">object</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-kind-parameter">object</span> <span class="tsd-signature-keyword">is</span> <a href="../classes/Crypto.html" class="tsd-signature-type tsd-kind-class">Crypto</a><a href="#iscrypto" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Checks if an object is an instance of Crypto.</p>
|
|
2
|
+
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">object</span>: <span class="tsd-signature-type">any</span></span><div class="tsd-comment tsd-typography"><p>The object to check.</p>
|
|
3
|
+
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-kind-parameter">object</span> <span class="tsd-signature-keyword">is</span> <a href="../classes/Crypto.html" class="tsd-signature-type tsd-kind-class">Crypto</a></h4><p>Returns true if the object is an instance of Crypto, false otherwise.</p>
|
|
4
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vvlad1973/vvlad1973-crypto/blob/c6e7262c1966961460db0e1915a90ab637f083c8/src/crypto.ts#L13">crypto.ts:13</a></li></ul></aside></div></li></ul></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">@vvlad1973/crypto - v2.1.0</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="./"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>@vvlad1973/crypto - v2.1.0</title><meta name="description" content="Documentation for @vvlad1973/crypto"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script defer src="assets/main.js"></script><script async src="assets/icons.js" id="tsd-icons-script"></script><script async src="assets/search.js" id="tsd-search-script"></script><script async src="assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="index.html" class="title">@vvlad1973/crypto - v2.1.0</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><h1>@vvlad1973/crypto - v2.1.0</h1></div><h2>Hierarchy Summary</h2></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="modules.html">@vvlad1973/crypto - v2.1.0</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
package/docs/index.html
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="./"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>@vvlad1973/crypto - v2.1.0</title><meta name="description" content="Documentation for @vvlad1973/crypto"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script defer src="assets/main.js"></script><script async src="assets/icons.js" id="tsd-icons-script"></script><script async src="assets/search.js" id="tsd-search-script"></script><script async src="assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="index.html" class="title">@vvlad1973/crypto - v2.1.0</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><h1>@vvlad1973/crypto - v2.1.0</h1></div><div class="tsd-panel tsd-typography"><h1 id="vvlad1973crypto" class="tsd-anchor-link">@vvlad1973/crypto<a href="#vvlad1973crypto" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h1><p>A simple TypeScript class for encrypting and decrypting text using specified cryptographic parameters (algorithm, password, etc.).</p>
|
|
2
|
+
<p>This class is a wrapper for the <a href="https://www.npmjs.com/package/aes-js">aes-js library</a>.</p>
|
|
3
|
+
<h2 id="installation" class="tsd-anchor-link">Installation<a href="#installation" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>You can install the package via npm:</p>
|
|
4
|
+
<pre><code class="bash"><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">install</span><span class="hl-1"> </span><span class="hl-2">vvlad1973-crypto</span>
|
|
5
|
+
</code><button type="button">Copy</button></pre>
|
|
6
|
+
|
|
7
|
+
<h2 id="usage" class="tsd-anchor-link">Usage<a href="#usage" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Here are some examples of how to use the Crypto class in your project.</p>
|
|
8
|
+
<h3 id="importing-the-crypto-class" class="tsd-anchor-link">Importing the Crypto Class<a href="#importing-the-crypto-class" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>In a CommonJS module environment (Node.js):</p>
|
|
9
|
+
<pre><code class="javascript"><br/><span class="hl-3">const</span><span class="hl-1"> { </span><span class="hl-4">Crypto</span><span class="hl-1"> } = </span><span class="hl-0">require</span><span class="hl-1">(</span><span class="hl-2">'vvlad1973-crypto'</span><span class="hl-1">);</span>
|
|
10
|
+
</code><button type="button">Copy</button></pre>
|
|
11
|
+
|
|
12
|
+
<p>In an ES module environment:</p>
|
|
13
|
+
<pre><code class="javascript"><br/><span class="hl-5">import</span><span class="hl-1"> { </span><span class="hl-6">Crypto</span><span class="hl-1"> } </span><span class="hl-5">from</span><span class="hl-1"> </span><span class="hl-2">'vvlad1973-crypto'</span><span class="hl-1">;</span>
|
|
14
|
+
</code><button type="button">Copy</button></pre>
|
|
15
|
+
|
|
16
|
+
<h3 id="example-encrypting-and-decrypting-text" class="tsd-anchor-link">Example: Encrypting and Decrypting Text<a href="#example-encrypting-and-decrypting-text" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><pre><code class="javascript"><br/><span class="hl-3">const</span><span class="hl-1"> </span><span class="hl-4">password</span><span class="hl-1"> = </span><span class="hl-2">'your-password'</span><span class="hl-1">;</span><br/><span class="hl-3">const</span><span class="hl-1"> </span><span class="hl-4">salt</span><span class="hl-1"> = </span><span class="hl-2">'your-salt'</span><span class="hl-1">;</span><br/><br/><span class="hl-7">// Create an instance of the Crypto class</span><br/><span class="hl-3">const</span><span class="hl-1"> </span><span class="hl-4">crypto</span><span class="hl-1"> = </span><span class="hl-3">new</span><span class="hl-1"> </span><span class="hl-0">Crypto</span><span class="hl-1">(</span><span class="hl-6">password</span><span class="hl-1">, </span><span class="hl-6">salt</span><span class="hl-1">);</span><br/><br/><span class="hl-7">// Encrypt a text</span><br/><span class="hl-3">const</span><span class="hl-1"> </span><span class="hl-4">plainText</span><span class="hl-1"> = </span><span class="hl-2">'Hello, World!'</span><span class="hl-1">;</span><br/><span class="hl-3">const</span><span class="hl-1"> </span><span class="hl-4">encryptedText</span><span class="hl-1"> = </span><span class="hl-6">crypto</span><span class="hl-1">.</span><span class="hl-0">encrypt</span><span class="hl-1">(</span><span class="hl-6">plainText</span><span class="hl-1">);</span><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-2">'Encrypted:'</span><span class="hl-1">, </span><span class="hl-6">encryptedText</span><span class="hl-1">);</span><br/><br/><span class="hl-7">// Decrypt the text</span><br/><span class="hl-3">const</span><span class="hl-1"> </span><span class="hl-4">decryptedText</span><span class="hl-1"> = </span><span class="hl-6">crypto</span><span class="hl-1">.</span><span class="hl-0">decrypt</span><span class="hl-1">(</span><span class="hl-6">encryptedText</span><span class="hl-1">);</span><br/><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-2">'Decrypted:'</span><span class="hl-1">, </span><span class="hl-6">decryptedText</span><span class="hl-1">);</span>
|
|
17
|
+
</code><button type="button">Copy</button></pre>
|
|
18
|
+
|
|
19
|
+
<h2 id="api" class="tsd-anchor-link">API<a href="#api" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><h3 id="new-cryptopassword-string-salt-string-algorithm-string-sha512-iterations-number--1000-keylength-number--32-iv-number--5" class="tsd-anchor-link">new Crypto(password: string, salt: string, algorithm: string = 'SHA512', iterations: number = 1000, keyLength: number = 32, iv: number = 5)<a href="#new-cryptopassword-string-salt-string-algorithm-string-sha512-iterations-number--1000-keylength-number--32-iv-number--5" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><ul>
|
|
20
|
+
<li>password: The password used for key derivation.</li>
|
|
21
|
+
<li>salt: The salt used for key derivation.</li>
|
|
22
|
+
<li>algorithm: The hash algorithm to use for key derivation. Default is SHA512.</li>
|
|
23
|
+
<li>iterations: The number of iterations to use for key derivation. Default is 1000.</li>
|
|
24
|
+
<li>keyLength: The length of the derived key in bytes. Default is 32.</li>
|
|
25
|
+
<li>iv: The initialization vector for the AES encryption. Default is 5.</li>
|
|
26
|
+
</ul>
|
|
27
|
+
<h3 id="encrypttext-string-string" class="tsd-anchor-link">encrypt(text: string): string<a href="#encrypttext-string-string" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>Encrypts the given text and returns the encrypted text as a hex string.</p>
|
|
28
|
+
<ul>
|
|
29
|
+
<li>text: The plain text to encrypt.</li>
|
|
30
|
+
<li>returns: The encrypted text as a hex string.</li>
|
|
31
|
+
</ul>
|
|
32
|
+
<h3 id="decrypttext-string-string" class="tsd-anchor-link">decrypt(text: string): string<a href="#decrypttext-string-string" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>Decrypts the given encrypted text and returns the decrypted plain text.</p>
|
|
33
|
+
<ul>
|
|
34
|
+
<li>text: The encrypted text as a hex string.</li>
|
|
35
|
+
<li>returns: The decrypted plain text.</li>
|
|
36
|
+
</ul>
|
|
37
|
+
<h2 id="running-tests" class="tsd-anchor-link">Running Tests<a href="#running-tests" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>To run tests, use the following command:</p>
|
|
38
|
+
<pre><code class="bash"><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">test</span>
|
|
39
|
+
</code><button type="button">Copy</button></pre>
|
|
40
|
+
|
|
41
|
+
<h2 id="license" class="tsd-anchor-link">License<a href="#license" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>This project is licensed under the MIT License with Commercial Use - see the LICENSE file for details.</p>
|
|
42
|
+
<h2 id="author" class="tsd-anchor-link">Author<a href="#author" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Vladislav Vnukovskiy <a href="mailto:vvlad1973@gmail.com">vvlad1973@gmail.com</a></p>
|
|
43
|
+
</div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg><h3>On This Page</h3></summary><div class="tsd-accordion-details"><a href="#vvlad1973crypto"><span>@vvlad1973/crypto</span></a><ul><li><a href="#installation"><span>Installation</span></a></li><li><a href="#usage"><span>Usage</span></a></li><li><ul><li><a href="#importing-the-crypto-class"><span>Importing the <wbr/>Crypto <wbr/>Class</span></a></li><li><a href="#example-encrypting-and-decrypting-text"><span>Example: <wbr/>Encrypting and <wbr/>Decrypting <wbr/>Text</span></a></li></ul></li><li><a href="#api"><span>API</span></a></li><li><ul><li><a href="#new-cryptopassword-string-salt-string-algorithm-string-sha512-iterations-number--1000-keylength-number--32-iv-number--5"><span>new <wbr/>Crypto(password: string, salt: string, algorithm: string = '<wbr/>SHA512', iterations: number = 1000, key<wbr/>Length: number = 32, iv: number = 5)</span></a></li><li><a href="#encrypttext-string-string"><span>encrypt(text: string): string</span></a></li><li><a href="#decrypttext-string-string"><span>decrypt(text: string): string</span></a></li></ul></li><li><a href="#running-tests"><span>Running <wbr/>Tests</span></a></li><li><a href="#license"><span>License</span></a></li><li><a href="#author"><span>Author</span></a></li></ul></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="modules.html">@vvlad1973/crypto - v2.1.0</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>CryptoOptions | @vvlad1973/crypto - v2.1.0</title><meta name="description" content="Documentation for @vvlad1973/crypto"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@vvlad1973/crypto - v2.1.0</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">CryptoOptions</a></li></ul><h1>Interface CryptoOptions</h1></div><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><p>Interface representing the set of parameters to create an instance of the Crypto class.
|
|
2
|
+
CryptoOptions</p>
|
|
3
|
+
</div></section><div class="tsd-signature"><span class="tsd-signature-keyword">interface</span> <span class="tsd-kind-interface">CryptoOptions</span> <span class="tsd-signature-symbol">{</span><br/> <a class="tsd-kind-property" href="#password">password</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#salt">salt</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#algorithm">algorithm</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#iterations">iterations</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#keylength">keyLength</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/> <a class="tsd-kind-property" href="#iv">iv</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">Buffer</span><span class="tsd-signature-symbol">;</span><br/><span class="tsd-signature-symbol">}</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vvlad1973/vvlad1973-crypto/blob/c6e7262c1966961460db0e1915a90ab637f083c8/src/crypto.ts#L32">crypto.ts:32</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h5 class="tsd-index-heading uppercase">Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="#password" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>password</span></a>
|
|
4
|
+
<a href="#salt" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>salt</span></a>
|
|
5
|
+
<a href="#algorithm" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>algorithm?</span></a>
|
|
6
|
+
<a href="#iterations" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>iterations?</span></a>
|
|
7
|
+
<a href="#keylength" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>key<wbr/>Length?</span></a>
|
|
8
|
+
<a href="#iv" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>iv?</span></a>
|
|
9
|
+
</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Properties</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="password"><span>password</span><a href="#password" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">password</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><div class="tsd-comment tsd-typography"><p>The password used for key derivation.</p>
|
|
10
|
+
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vvlad1973/vvlad1973-crypto/blob/c6e7262c1966961460db0e1915a90ab637f083c8/src/crypto.ts#L33">crypto.ts:33</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="salt"><span>salt</span><a href="#salt" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">salt</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><div class="tsd-comment tsd-typography"><p>The salt used for key derivation.</p>
|
|
11
|
+
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vvlad1973/vvlad1973-crypto/blob/c6e7262c1966961460db0e1915a90ab637f083c8/src/crypto.ts#L34">crypto.ts:34</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="algorithm"><code class="tsd-tag">Optional</code><span>algorithm</span><a href="#algorithm" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">algorithm</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span></div><div class="tsd-comment tsd-typography"><p>The hash algorithm to use for key derivation.</p>
|
|
12
|
+
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vvlad1973/vvlad1973-crypto/blob/c6e7262c1966961460db0e1915a90ab637f083c8/src/crypto.ts#L35">crypto.ts:35</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="iterations"><code class="tsd-tag">Optional</code><span>iterations</span><a href="#iterations" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">iterations</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div><div class="tsd-comment tsd-typography"><p>The number of iterations to use for key derivation.</p>
|
|
13
|
+
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vvlad1973/vvlad1973-crypto/blob/c6e7262c1966961460db0e1915a90ab637f083c8/src/crypto.ts#L36">crypto.ts:36</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="keylength"><code class="tsd-tag">Optional</code><span>key<wbr/>Length</span><a href="#keylength" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">keyLength</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div><div class="tsd-comment tsd-typography"><p>The length of the derived key in bytes.</p>
|
|
14
|
+
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vvlad1973/vvlad1973-crypto/blob/c6e7262c1966961460db0e1915a90ab637f083c8/src/crypto.ts#L37">crypto.ts:37</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="iv"><code class="tsd-tag">Optional</code><span>iv</span><a href="#iv" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">iv</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">Buffer</span></div><div class="tsd-comment tsd-typography"><p>The initialization vector for the AES encryption.</p>
|
|
15
|
+
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/vvlad1973/vvlad1973-crypto/blob/c6e7262c1966961460db0e1915a90ab637f083c8/src/crypto.ts#L38">crypto.ts:38</a></li></ul></aside></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#password"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>password</span></a><a href="#salt"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>salt</span></a><a href="#algorithm"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>algorithm</span></a><a href="#iterations"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>iterations</span></a><a href="#keylength"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>key<wbr/>Length</span></a><a href="#iv"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>iv</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">@vvlad1973/crypto - v2.1.0</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="./"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>@vvlad1973/crypto - v2.1.0</title><meta name="description" content="Documentation for @vvlad1973/crypto"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script defer src="assets/main.js"></script><script async src="assets/icons.js" id="tsd-icons-script"></script><script async src="assets/search.js" id="tsd-search-script"></script><script async src="assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="index.html" class="title">@vvlad1973/crypto - v2.1.0</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"></ul><h1>@vvlad1973/crypto - v2.1.0</h1></div><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Classes"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg><h2>Classes</h2></summary><dl class="tsd-member-summaries"><dt class="tsd-member-summary" id="crypto"><span class="tsd-member-summary-name"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Class"><use href="assets/icons.svg#icon-128"></use></svg><a href="classes/Crypto.html">Crypto</a><a href="#crypto" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></span></dt><dd class="tsd-member-summary"></dd></dl></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Interfaces"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg><h2>Interfaces</h2></summary><dl class="tsd-member-summaries"><dt class="tsd-member-summary" id="cryptooptions"><span class="tsd-member-summary-name"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Interface"><use href="assets/icons.svg#icon-256"></use></svg><a href="interfaces/CryptoOptions.html">CryptoOptions</a><a href="#cryptooptions" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></span></dt><dd class="tsd-member-summary"></dd></dl></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Functions"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg><h2>Functions</h2></summary><dl class="tsd-member-summaries"><dt class="tsd-member-summary" id="iscrypto"><span class="tsd-member-summary-name"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Function"><use href="assets/icons.svg#icon-64"></use></svg><a href="functions/isCrypto.html">isCrypto</a><a href="#iscrypto" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></span></dt><dd class="tsd-member-summary"></dd></dl></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-References"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg><h2>References</h2></summary><dl class="tsd-member-summaries"><dt class="tsd-member-summary" id="default"><span class="tsd-member-summary-name"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Class"><use href="assets/icons.svg#icon-128"></use></svg><span>default</span><span> → </span><a href="classes/Crypto.html">Crypto</a><a href="#default" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></span></dt><dd class="tsd-member-summary"></dd></dl></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg><h3>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Classes"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg>Classes</summary><div><a href="#crypto"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Class"><use href="assets/icons.svg#icon-128"></use></svg><span>Crypto</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Interfaces"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg>Interfaces</summary><div><a href="#cryptooptions"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Interface"><use href="assets/icons.svg#icon-256"></use></svg><span>Crypto<wbr/>Options</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Functions"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg>Functions</summary><div><a href="#iscrypto"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Function"><use href="assets/icons.svg#icon-64"></use></svg><span>is<wbr/>Crypto</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-References"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg>References</summary><div><a href="#default"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Reference"><use href="assets/icons.svg#icon-4194304"></use></svg><span>default</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="modules.html" class="current">@vvlad1973/crypto - v2.1.0</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vvlad1973/crypto",
|
|
3
|
+
"version": "2.1.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "vitest run",
|
|
9
|
+
"test:watch": "vitest",
|
|
10
|
+
"test:ui": "vitest --ui",
|
|
11
|
+
"test:coverage": "vitest run --coverage",
|
|
12
|
+
"changelog": "npx gen-changelog",
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"doc": "typedoc"
|
|
15
|
+
},
|
|
16
|
+
"author": "Vladislav Vnukovskiy <vvlad1973@gmail.com>",
|
|
17
|
+
"license": "MIT with Commercial Use",
|
|
18
|
+
"description": "A JavaScript class for encrypting and decrypting text using specified cryptographic parameters (algorithm, password, etc.)",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^25.0.3",
|
|
21
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
22
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
23
|
+
"@vitest/ui": "^3.2.4",
|
|
24
|
+
"@vvlad1973/gen-changelog": "^1.1.5",
|
|
25
|
+
"pretty-format": "^29.7.0",
|
|
26
|
+
"typedoc": "^0.28.15",
|
|
27
|
+
"vitest": "^3.2.4"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"cryptography",
|
|
31
|
+
"aes",
|
|
32
|
+
"encryption",
|
|
33
|
+
"decryption",
|
|
34
|
+
"crypto",
|
|
35
|
+
"security",
|
|
36
|
+
"aes-js",
|
|
37
|
+
"wrapper",
|
|
38
|
+
"password",
|
|
39
|
+
"salt",
|
|
40
|
+
"hash",
|
|
41
|
+
"key derivation",
|
|
42
|
+
"pbkdf2"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { describe, it, beforeEach, expect } from 'vitest';
|
|
2
|
+
import { randomBytes } from 'crypto';
|
|
3
|
+
import Crypto, { CryptoOptions, isCrypto } from '../crypto.js';
|
|
4
|
+
|
|
5
|
+
describe('Crypto', () => {
|
|
6
|
+
const plainText = 'Hello, World!';
|
|
7
|
+
let options: CryptoOptions;
|
|
8
|
+
let password: string;
|
|
9
|
+
let salt: string;
|
|
10
|
+
let algorithm: string;
|
|
11
|
+
let iterations: number;
|
|
12
|
+
let keyLength: number;
|
|
13
|
+
let iv: number;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
options = {
|
|
17
|
+
password: 'testPassword',
|
|
18
|
+
salt: 'testSalt',
|
|
19
|
+
algorithm: 'SHA512',
|
|
20
|
+
iterations: 1000,
|
|
21
|
+
keyLength: 32,
|
|
22
|
+
iv: 5,
|
|
23
|
+
};
|
|
24
|
+
password = 'testPassword';
|
|
25
|
+
salt = 'testSalt';
|
|
26
|
+
algorithm = 'SHA512';
|
|
27
|
+
iterations = 1000;
|
|
28
|
+
keyLength = 32;
|
|
29
|
+
iv = 5;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should initialize with CryptoOptions object', () => {
|
|
33
|
+
const crypto = new Crypto(options);
|
|
34
|
+
expect(crypto).toBeDefined();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should initialize with separate parameters', () => {
|
|
38
|
+
const crypto = new Crypto(
|
|
39
|
+
password,
|
|
40
|
+
salt,
|
|
41
|
+
algorithm,
|
|
42
|
+
iterations,
|
|
43
|
+
keyLength,
|
|
44
|
+
iv
|
|
45
|
+
);
|
|
46
|
+
expect(crypto).toBeDefined();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should return UUIDv4', () => {
|
|
50
|
+
const crypto = new Crypto(options);
|
|
51
|
+
const uuid = Crypto.getUUID();
|
|
52
|
+
const uuidv4Regex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
53
|
+
expect(uuid).toMatch(uuidv4Regex);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should encrypt and decrypt text correctly using ICryptoOptions', () => {
|
|
57
|
+
const crypto = new Crypto(options);
|
|
58
|
+
const encryptedText = crypto.encrypt(plainText);
|
|
59
|
+
const decryptedText = crypto.decrypt(encryptedText);
|
|
60
|
+
expect(decryptedText).toBe(plainText);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should encrypt and decrypt text correctly using separate parameters', () => {
|
|
64
|
+
const crypto = new Crypto(
|
|
65
|
+
password,
|
|
66
|
+
salt,
|
|
67
|
+
algorithm,
|
|
68
|
+
iterations,
|
|
69
|
+
keyLength,
|
|
70
|
+
iv
|
|
71
|
+
);
|
|
72
|
+
const encryptedText = crypto.encrypt(plainText);
|
|
73
|
+
const decryptedText = crypto.decrypt(encryptedText);
|
|
74
|
+
expect(decryptedText).toBe(plainText);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should handle default values for optional parameters', () => {
|
|
78
|
+
const cryptoWithDefaults = new Crypto(password, salt);
|
|
79
|
+
const encryptedText = cryptoWithDefaults.encrypt(plainText);
|
|
80
|
+
const decryptedText = cryptoWithDefaults.decrypt(encryptedText);
|
|
81
|
+
expect(decryptedText).toBe(plainText);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should initialize with Buffer IV using options object', () => {
|
|
85
|
+
const ivBuffer = randomBytes(16);
|
|
86
|
+
const crypto = new Crypto({
|
|
87
|
+
password,
|
|
88
|
+
salt,
|
|
89
|
+
algorithm,
|
|
90
|
+
iterations,
|
|
91
|
+
keyLength,
|
|
92
|
+
iv: ivBuffer,
|
|
93
|
+
});
|
|
94
|
+
const encryptedText = crypto.encrypt(plainText);
|
|
95
|
+
const decryptedText = crypto.decrypt(encryptedText);
|
|
96
|
+
expect(decryptedText).toBe(plainText);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('should initialize with Buffer IV using separate parameters', () => {
|
|
100
|
+
const ivBuffer = randomBytes(16);
|
|
101
|
+
const crypto = new Crypto(
|
|
102
|
+
password,
|
|
103
|
+
salt,
|
|
104
|
+
algorithm,
|
|
105
|
+
iterations,
|
|
106
|
+
keyLength,
|
|
107
|
+
ivBuffer
|
|
108
|
+
);
|
|
109
|
+
const encryptedText = crypto.encrypt(plainText);
|
|
110
|
+
const decryptedText = crypto.decrypt(encryptedText);
|
|
111
|
+
expect(decryptedText).toBe(plainText);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('should initialize without IV (random generation via options)', () => {
|
|
115
|
+
const crypto1 = new Crypto({ password, salt });
|
|
116
|
+
const crypto2 = new Crypto({ password, salt });
|
|
117
|
+
const encrypted1 = crypto1.encrypt(plainText);
|
|
118
|
+
const encrypted2 = crypto2.encrypt(plainText);
|
|
119
|
+
// Should produce different encrypted results due to different random IVs
|
|
120
|
+
expect(encrypted1).not.toBe(encrypted2);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should handle empty string encryption and decryption', () => {
|
|
124
|
+
const crypto = new Crypto(options);
|
|
125
|
+
const emptyText = '';
|
|
126
|
+
const encryptedText = crypto.encrypt(emptyText);
|
|
127
|
+
const decryptedText = crypto.decrypt(encryptedText);
|
|
128
|
+
expect(decryptedText).toBe(emptyText);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('should handle Unicode characters', () => {
|
|
132
|
+
const crypto = new Crypto(options);
|
|
133
|
+
const unicodeText = '🔐 Encryption test 中文 العربية';
|
|
134
|
+
const encryptedText = crypto.encrypt(unicodeText);
|
|
135
|
+
const decryptedText = crypto.decrypt(encryptedText);
|
|
136
|
+
expect(decryptedText).toBe(unicodeText);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should handle different hash algorithms', () => {
|
|
140
|
+
const crypto256 = new Crypto(password, salt, 'sha256', iterations, keyLength, iv);
|
|
141
|
+
const encryptedText = crypto256.encrypt(plainText);
|
|
142
|
+
const decryptedText = crypto256.decrypt(encryptedText);
|
|
143
|
+
expect(decryptedText).toBe(plainText);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('should handle different key lengths', () => {
|
|
147
|
+
// AES-256-CTR requires 32 bytes key, testing with valid 32 bytes
|
|
148
|
+
const crypto32 = new Crypto(password, salt, algorithm, iterations, 32, iv);
|
|
149
|
+
const encryptedText = crypto32.encrypt(plainText);
|
|
150
|
+
const decryptedText = crypto32.decrypt(encryptedText);
|
|
151
|
+
expect(decryptedText).toBe(plainText);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('should handle different iteration counts', () => {
|
|
155
|
+
const crypto = new Crypto(password, salt, algorithm, 5000, keyLength, iv);
|
|
156
|
+
const encryptedText = crypto.encrypt(plainText);
|
|
157
|
+
const decryptedText = crypto.decrypt(encryptedText);
|
|
158
|
+
expect(decryptedText).toBe(plainText);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
describe('isCrypto', () => {
|
|
163
|
+
const validCryptoOptions: CryptoOptions = {
|
|
164
|
+
password: 'testPassword',
|
|
165
|
+
salt: 'testSalt',
|
|
166
|
+
algorithm: 'SHA512',
|
|
167
|
+
iterations: 1000,
|
|
168
|
+
keyLength: 32,
|
|
169
|
+
iv: 5,
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
it('should return true for a valid Crypto instance created with ICryptoOptions', () => {
|
|
173
|
+
const crypto = new Crypto(validCryptoOptions);
|
|
174
|
+
expect(isCrypto(crypto)).toBe(true);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('should return true for a valid Crypto instance created with separate parameters', () => {
|
|
178
|
+
const crypto = new Crypto(
|
|
179
|
+
validCryptoOptions.password,
|
|
180
|
+
validCryptoOptions.salt,
|
|
181
|
+
validCryptoOptions.algorithm,
|
|
182
|
+
validCryptoOptions.iterations,
|
|
183
|
+
validCryptoOptions.keyLength,
|
|
184
|
+
validCryptoOptions.iv
|
|
185
|
+
);
|
|
186
|
+
expect(isCrypto(crypto)).toBe(true);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('should return false for null', () => {
|
|
190
|
+
const nullObject = null;
|
|
191
|
+
expect(isCrypto(nullObject)).toBe(false);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('should return false for undefined', () => {
|
|
195
|
+
const undefinedObject = undefined;
|
|
196
|
+
expect(isCrypto(undefinedObject)).toBe(false);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('should return false for a plain object without encrypt and decrypt methods', () => {
|
|
200
|
+
const plainObject = {
|
|
201
|
+
someMethod: () => {},
|
|
202
|
+
};
|
|
203
|
+
expect(isCrypto(plainObject)).toBe(false);
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
describe('Compatibility with previous version', () => {
|
|
208
|
+
|
|
209
|
+
const plainText = 'Проверка связи';
|
|
210
|
+
let options: CryptoOptions;
|
|
211
|
+
let encText = 'a4661cb701751a895f65418ed488faad33da3090d05ad661f0a7a9';
|
|
212
|
+
|
|
213
|
+
beforeEach(() => {
|
|
214
|
+
options = {
|
|
215
|
+
algorithm: 'SHA512',
|
|
216
|
+
iv: 5,
|
|
217
|
+
keyLength: 32,
|
|
218
|
+
iterations: 1000,
|
|
219
|
+
password: 'password',
|
|
220
|
+
salt: 'saltsaltsalt',
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('should return correct string', () => {
|
|
225
|
+
const crypto = new Crypto(options);
|
|
226
|
+
|
|
227
|
+
const decryptedText = crypto.decrypt(encText);
|
|
228
|
+
expect(decryptedText).toBe(plainText);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('should return correct encrypt-decrypt', () => {
|
|
232
|
+
const crypto = new Crypto(options);
|
|
233
|
+
|
|
234
|
+
const encryptedText = crypto.encrypt(plainText);
|
|
235
|
+
const decryptedText = crypto.decrypt(encryptedText);
|
|
236
|
+
expect(decryptedText).toBe(plainText);
|
|
237
|
+
});
|
|
238
|
+
});
|