@@ -6285,28 +6285,29 @@ paths:
62856285
62866286 #### Example encrypting a secret using Node.js
62876287
6288- Encrypt your secret using the [tweetsodium ](https://github. com/github/tweetsodium ) library.
6288+ Encrypt your secret using the [libsodium-wrappers ](https://www.npmjs. com/package/libsodium-wrappers ) library.
62896289
62906290 ```
6291- const sodium = require('tweetsodium');
6292-
6293- const key = "base64-encoded-public-key";
6294- const value = "plain-text-secret";
6291+ const sodium = require('libsodium-wrappers')
6292+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
6293+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
62956294
6296- // Convert the message and key to Uint8Array's (Buffer implements that interface)
6297- const messageBytes = Buffer.from(value);
6298- const keyBytes = Buffer.from(key, 'base64');
6295+ //Check if libsodium is ready and then proceed.
6296+ sodium.ready.then(() => {
6297+ // Convert Secret & Base64 key to Uint8Array.
6298+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
6299+ let binsec = sodium.from_string(secret)
62996300
6300- // Encrypt using LibSodium.
6301- const encryptedBytes = sodium.seal(messageBytes, keyBytes);
6301+ // Encrypt the secret using LibSodium
6302+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
63026303
6303- // Base64 the encrypted secret
6304- const encrypted = Buffer.from(encryptedBytes).toString('base64');
6304+ // Convert encrypted Uint8Array to Base64
6305+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
63056306
6306- console.log(encrypted);
6307+ console.log(output)
6308+ });
63076309 ```
63086310
6309-
63106311 #### Example encrypting a secret using Python
63116312
63126313 Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3.
@@ -7011,26 +7012,23 @@ paths:
70117012 Encrypt your secret using the [libsodium-wrappers](https://www.npmjs.com/package/libsodium-wrappers) library.
70127013
70137014 ```
7014- // Written with ❤️ by PSJ and free to use under The Unlicense.
7015- const sodium=require('libsodium-wrappers')
7016- const secret = 'plain-text-secret' // replace with secret before running the script.
7017- const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key.
7015+ const sodium = require('libsodium-wrappers')
7016+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
7017+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
70187018
70197019 //Check if libsodium is ready and then proceed.
7020+ sodium.ready.then(() => {
7021+ // Convert Secret & Base64 key to Uint8Array.
7022+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
7023+ let binsec = sodium.from_string(secret)
70207024
7021- sodium.ready.then( ()=>{
7025+ //Encrypt the secret using LibSodium
7026+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
70227027
7023- // Convert Secret & Base64 key to Uint8Array.
7024- let binkey= sodium.from_base64(key, sodium.base64_variants.ORIGINAL) //Equivalent of Buffer.from(key, 'base64')
7025- let binsec= sodium.from_string(secret) // Equivalent of Buffer.from(secret)
7028+ // Convert encrypted Uint8Array to Base64
7029+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
70267030
7027- //Encrypt the secret using LibSodium
7028- let encBytes= sodium.crypto_box_seal(binsec,binkey) // Similar to tweetsodium.seal(binsec,binkey)
7029-
7030- // Convert encrypted Uint8Array to Base64
7031- let output=sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL) //Equivalent of Buffer.from(encBytes).toString('base64')
7032-
7033- console.log(output)
7031+ console.log(output)
70347032 });
70357033 ```
70367034
@@ -7709,28 +7707,29 @@ paths:
77097707
77107708 #### Example encrypting a secret using Node.js
77117709
7712- Encrypt your secret using the [tweetsodium ](https://github. com/github/tweetsodium ) library.
7710+ Encrypt your secret using the [libsodium-wrappers ](https://www.npmjs. com/package/libsodium-wrappers ) library.
77137711
77147712 ```
7715- const sodium = require('tweetsodium');
7713+ const sodium = require('libsodium-wrappers')
7714+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
7715+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
77167716
7717- const key = "base64-encoded-public-key";
7718- const value = "plain-text-secret";
7719-
7720- // Convert the message and key to Uint8Array's (Buffer implements that interface)
7721- const messageBytes = Buffer.from(value);
7722- const keyBytes = Buffer.from(key, 'base64');
7717+ //Check if libsodium is ready and then proceed.
7718+ sodium.ready.then(() => {
7719+ // Convert Secret & Base64 key to Uint8Array.
7720+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
7721+ let binsec = sodium.from_string(secret)
77237722
7724- // Encrypt using LibSodium.
7725- const encryptedBytes = sodium.seal(messageBytes, keyBytes);
7723+ // Encrypt the secret using LibSodium
7724+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
77267725
7727- // Base64 the encrypted secret
7728- const encrypted = Buffer.from(encryptedBytes).toString('base64');
7726+ // Convert encrypted Uint8Array to Base64
7727+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
77297728
7730- console.log(encrypted);
7729+ console.log(output)
7730+ });
77317731 ```
77327732
7733-
77347733 #### Example encrypting a secret using Python
77357734
77367735 Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3.
@@ -15882,28 +15881,29 @@ paths:
1588215881
1588315882 #### Example encrypting a secret using Node.js
1588415883
15885- Encrypt your secret using the [tweetsodium ](https://github. com/github/tweetsodium ) library.
15884+ Encrypt your secret using the [libsodium-wrappers ](https://www.npmjs. com/package/libsodium-wrappers ) library.
1588615885
1588715886 ```
15888- const sodium = require('tweetsodium');
15887+ const sodium = require('libsodium-wrappers')
15888+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
15889+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
1588915890
15890- const key = "base64-encoded-public-key";
15891- const value = "plain-text-secret";
15892-
15893- // Convert the message and key to Uint8Array's (Buffer implements that interface)
15894- const messageBytes = Buffer.from(value);
15895- const keyBytes = Buffer.from(key, 'base64');
15891+ //Check if libsodium is ready and then proceed.
15892+ sodium.ready.then(() => {
15893+ // Convert Secret & Base64 key to Uint8Array.
15894+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
15895+ let binsec = sodium.from_string(secret)
1589615896
15897- // Encrypt using LibSodium.
15898- const encryptedBytes = sodium.seal(messageBytes, keyBytes);
15897+ // Encrypt the secret using LibSodium
15898+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
1589915899
15900- // Base64 the encrypted secret
15901- const encrypted = Buffer.from(encryptedBytes).toString('base64');
15900+ // Convert encrypted Uint8Array to Base64
15901+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
1590215902
15903- console.log(encrypted);
15903+ console.log(output)
15904+ });
1590415905 ```
1590515906
15906-
1590715907 #### Example encrypting a secret using Python
1590815908
1590915909 Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3.
@@ -20725,28 +20725,29 @@ paths:
2072520725
2072620726 #### Example of encrypting a secret using Node.js
2072720727
20728- Encrypt your secret using the [tweetsodium ](https://github. com/github/tweetsodium ) library.
20728+ Encrypt your secret using the [libsodium-wrappers ](https://www.npmjs. com/package/libsodium-wrappers ) library.
2072920729
2073020730 ```
20731- const sodium = require('tweetsodium');
20732-
20733- const key = "base64-encoded-public-key";
20734- const value = "plain-text-secret";
20731+ const sodium = require('libsodium-wrappers')
20732+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
20733+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
2073520734
20736- // Convert the message and key to Uint8Array's (Buffer implements that interface)
20737- const messageBytes = Buffer.from(value);
20738- const keyBytes = Buffer.from(key, 'base64');
20735+ //Check if libsodium is ready and then proceed.
20736+ sodium.ready.then(() => {
20737+ // Convert Secret & Base64 key to Uint8Array.
20738+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
20739+ let binsec = sodium.from_string(secret)
2073920740
20740- // Encrypt using LibSodium.
20741- const encryptedBytes = sodium.seal(messageBytes, keyBytes);
20741+ // Encrypt the secret using LibSodium
20742+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
2074220743
20743- // Base64 the encrypted secret
20744- const encrypted = Buffer.from(encryptedBytes).toString('base64');
20744+ // Convert encrypted Uint8Array to Base64
20745+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
2074520746
20746- console.log(encrypted);
20747+ console.log(output)
20748+ });
2074720749 ```
2074820750
20749-
2075020751 #### Example of encrypting a secret using Python
2075120752
2075220753 Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3.
@@ -22783,28 +22784,29 @@ paths:
2278322784
2278422785 #### Example encrypting a secret using Node.js
2278522786
22786- Encrypt your secret using the [tweetsodium ](https://github. com/github/tweetsodium ) library.
22787+ Encrypt your secret using the [libsodium-wrappers ](https://www.npmjs. com/package/libsodium-wrappers ) library.
2278722788
2278822789 ```
22789- const sodium = require('tweetsodium');
22790-
22791- const key = "base64-encoded-public-key";
22792- const value = "plain-text-secret";
22790+ const sodium = require('libsodium-wrappers')
22791+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
22792+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
2279322793
22794- // Convert the message and key to Uint8Array's (Buffer implements that interface)
22795- const messageBytes = Buffer.from(value);
22796- const keyBytes = Buffer.from(key, 'base64');
22794+ //Check if libsodium is ready and then proceed.
22795+ sodium.ready.then(() => {
22796+ // Convert Secret & Base64 key to Uint8Array.
22797+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
22798+ let binsec = sodium.from_string(secret)
2279722799
22798- // Encrypt using LibSodium.
22799- const encryptedBytes = sodium.seal(messageBytes, keyBytes);
22800+ // Encrypt the secret using LibSodium
22801+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
2280022802
22801- // Base64 the encrypted secret
22802- const encrypted = Buffer.from(encryptedBytes).toString('base64');
22803+ // Convert encrypted Uint8Array to Base64
22804+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
2280322805
22804- console.log(encrypted);
22806+ console.log(output)
22807+ });
2280522808 ```
2280622809
22807-
2280822810 #### Example encrypting a secret using Python
2280922811
2281022812 Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3.
@@ -33592,28 +33594,29 @@ paths:
3359233594
3359333595 #### Example encrypting a secret using Node.js
3359433596
33595- Encrypt your secret using the [tweetsodium ](https://github. com/github/tweetsodium ) library.
33597+ Encrypt your secret using the [libsodium-wrappers ](https://www.npmjs. com/package/libsodium-wrappers ) library.
3359633598
3359733599 ```
33598- const sodium = require('tweetsodium');
33600+ const sodium = require('libsodium-wrappers')
33601+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
33602+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
3359933603
33600- const key = "base64-encoded-public-key";
33601- const value = "plain-text-secret";
33602-
33603- // Convert the message and key to Uint8Array's (Buffer implements that interface)
33604- const messageBytes = Buffer.from(value);
33605- const keyBytes = Buffer.from(key, 'base64');
33604+ //Check if libsodium is ready and then proceed.
33605+ sodium.ready.then(() => {
33606+ // Convert Secret & Base64 key to Uint8Array.
33607+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
33608+ let binsec = sodium.from_string(secret)
3360633609
33607- // Encrypt using LibSodium.
33608- const encryptedBytes = sodium.seal(messageBytes, keyBytes);
33610+ // Encrypt the secret using LibSodium
33611+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
3360933612
33610- // Base64 the encrypted secret
33611- const encrypted = Buffer.from(encryptedBytes).toString('base64');
33613+ // Convert encrypted Uint8Array to Base64
33614+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
3361233615
33613- console.log(encrypted);
33616+ console.log(output)
33617+ });
3361433618 ```
3361533619
33616-
3361733620 #### Example encrypting a secret using Python
3361833621
3361933622 Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3.
@@ -36388,28 +36391,29 @@ paths:
3638836391
3638936392 #### Example encrypting a secret using Node.js
3639036393
36391- Encrypt your secret using the [tweetsodium ](https://github. com/github/tweetsodium ) library.
36394+ Encrypt your secret using the [libsodium-wrappers ](https://www.npmjs. com/package/libsodium-wrappers ) library.
3639236395
3639336396 ```
36394- const sodium = require('tweetsodium');
36397+ const sodium = require('libsodium-wrappers')
36398+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
36399+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
3639536400
36396- const key = "base64-encoded-public-key";
36397- const value = "plain-text-secret";
36398-
36399- // Convert the message and key to Uint8Array's (Buffer implements that interface)
36400- const messageBytes = Buffer.from(value);
36401- const keyBytes = Buffer.from(key, 'base64');
36401+ //Check if libsodium is ready and then proceed.
36402+ sodium.ready.then(() => {
36403+ // Convert Secret & Base64 key to Uint8Array.
36404+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
36405+ let binsec = sodium.from_string(secret)
3640236406
36403- // Encrypt using LibSodium.
36404- const encryptedBytes = sodium.seal(messageBytes, keyBytes);
36407+ // Encrypt the secret using LibSodium
36408+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
3640536409
36406- // Base64 the encrypted secret
36407- const encrypted = Buffer.from(encryptedBytes).toString('base64');
36410+ // Convert encrypted Uint8Array to Base64
36411+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
3640836412
36409- console.log(encrypted);
36413+ console.log(output)
36414+ });
3641036415 ```
3641136416
36412-
3641336417 #### Example encrypting a secret using Python
3641436418
3641536419 Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3.
0 commit comments