@@ -6262,28 +6262,29 @@ paths:
62626262
62636263 #### Example encrypting a secret using Node.js
62646264
6265- Encrypt your secret using the [tweetsodium ](https://github. com/github/tweetsodium ) library.
6265+ Encrypt your secret using the [libsodium-wrappers ](https://www.npmjs. com/package/libsodium-wrappers ) library.
62666266
62676267 ```
6268- const sodium = require('tweetsodium');
6269-
6270- const key = "base64-encoded-public-key";
6271- const value = "plain-text-secret";
6268+ const sodium = require('libsodium-wrappers')
6269+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
6270+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
62726271
6273- // Convert the message and key to Uint8Array's (Buffer implements that interface)
6274- const messageBytes = Buffer.from(value);
6275- const keyBytes = Buffer.from(key, 'base64');
6272+ //Check if libsodium is ready and then proceed.
6273+ sodium.ready.then(() => {
6274+ // Convert Secret & Base64 key to Uint8Array.
6275+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
6276+ let binsec = sodium.from_string(secret)
62766277
6277- // Encrypt using LibSodium.
6278- const encryptedBytes = sodium.seal(messageBytes, keyBytes);
6278+ // Encrypt the secret using LibSodium
6279+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
62796280
6280- // Base64 the encrypted secret
6281- const encrypted = Buffer.from(encryptedBytes).toString('base64');
6281+ // Convert encrypted Uint8Array to Base64
6282+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
62826283
6283- console.log(encrypted);
6284+ console.log(output)
6285+ });
62846286 ```
62856287
6286-
62876288 #### Example encrypting a secret using Python
62886289
62896290 Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3.
@@ -6988,26 +6989,23 @@ paths:
69886989 Encrypt your secret using the [libsodium-wrappers](https://www.npmjs.com/package/libsodium-wrappers) library.
69896990
69906991 ```
6991- // Written with ❤️ by PSJ and free to use under The Unlicense.
6992- const sodium=require('libsodium-wrappers')
6993- const secret = 'plain-text-secret' // replace with secret before running the script.
6994- const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key.
6992+ const sodium = require('libsodium-wrappers')
6993+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
6994+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
69956995
69966996 //Check if libsodium is ready and then proceed.
6997+ sodium.ready.then(() => {
6998+ // Convert Secret & Base64 key to Uint8Array.
6999+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
7000+ let binsec = sodium.from_string(secret)
69977001
6998- sodium.ready.then( ()=>{
7002+ //Encrypt the secret using LibSodium
7003+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
69997004
7000- // Convert Secret & Base64 key to Uint8Array.
7001- let binkey= sodium.from_base64(key, sodium.base64_variants.ORIGINAL) //Equivalent of Buffer.from(key, 'base64')
7002- let binsec= sodium.from_string(secret) // Equivalent of Buffer.from(secret)
7005+ // Convert encrypted Uint8Array to Base64
7006+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
70037007
7004- //Encrypt the secret using LibSodium
7005- let encBytes= sodium.crypto_box_seal(binsec,binkey) // Similar to tweetsodium.seal(binsec,binkey)
7006-
7007- // Convert encrypted Uint8Array to Base64
7008- let output=sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL) //Equivalent of Buffer.from(encBytes).toString('base64')
7009-
7010- console.log(output)
7008+ console.log(output)
70117009 });
70127010 ```
70137011
@@ -7686,28 +7684,29 @@ paths:
76867684
76877685 #### Example encrypting a secret using Node.js
76887686
7689- Encrypt your secret using the [tweetsodium ](https://github. com/github/tweetsodium ) library.
7687+ Encrypt your secret using the [libsodium-wrappers ](https://www.npmjs. com/package/libsodium-wrappers ) library.
76907688
76917689 ```
7692- const sodium = require('tweetsodium');
7690+ const sodium = require('libsodium-wrappers')
7691+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
7692+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
76937693
7694- const key = "base64-encoded-public-key";
7695- const value = "plain-text-secret";
7696-
7697- // Convert the message and key to Uint8Array's (Buffer implements that interface)
7698- const messageBytes = Buffer.from(value);
7699- const keyBytes = Buffer.from(key, 'base64');
7694+ //Check if libsodium is ready and then proceed.
7695+ sodium.ready.then(() => {
7696+ // Convert Secret & Base64 key to Uint8Array.
7697+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
7698+ let binsec = sodium.from_string(secret)
77007699
7701- // Encrypt using LibSodium.
7702- const encryptedBytes = sodium.seal(messageBytes, keyBytes);
7700+ // Encrypt the secret using LibSodium
7701+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
77037702
7704- // Base64 the encrypted secret
7705- const encrypted = Buffer.from(encryptedBytes).toString('base64');
7703+ // Convert encrypted Uint8Array to Base64
7704+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
77067705
7707- console.log(encrypted);
7706+ console.log(output)
7707+ });
77087708 ```
77097709
7710-
77117710 #### Example encrypting a secret using Python
77127711
77137712 Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3.
@@ -15823,28 +15822,29 @@ paths:
1582315822
1582415823 #### Example encrypting a secret using Node.js
1582515824
15826- Encrypt your secret using the [tweetsodium ](https://github. com/github/tweetsodium ) library.
15825+ Encrypt your secret using the [libsodium-wrappers ](https://www.npmjs. com/package/libsodium-wrappers ) library.
1582715826
1582815827 ```
15829- const sodium = require('tweetsodium');
15828+ const sodium = require('libsodium-wrappers')
15829+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
15830+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
1583015831
15831- const key = "base64-encoded-public-key";
15832- const value = "plain-text-secret";
15833-
15834- // Convert the message and key to Uint8Array's (Buffer implements that interface)
15835- const messageBytes = Buffer.from(value);
15836- const keyBytes = Buffer.from(key, 'base64');
15832+ //Check if libsodium is ready and then proceed.
15833+ sodium.ready.then(() => {
15834+ // Convert Secret & Base64 key to Uint8Array.
15835+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
15836+ let binsec = sodium.from_string(secret)
1583715837
15838- // Encrypt using LibSodium.
15839- const encryptedBytes = sodium.seal(messageBytes, keyBytes);
15838+ // Encrypt the secret using LibSodium
15839+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
1584015840
15841- // Base64 the encrypted secret
15842- const encrypted = Buffer.from(encryptedBytes).toString('base64');
15841+ // Convert encrypted Uint8Array to Base64
15842+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
1584315843
15844- console.log(encrypted);
15844+ console.log(output)
15845+ });
1584515846 ```
1584615847
15847-
1584815848 #### Example encrypting a secret using Python
1584915849
1585015850 Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3.
@@ -20654,28 +20654,29 @@ paths:
2065420654
2065520655 #### Example of encrypting a secret using Node.js
2065620656
20657- Encrypt your secret using the [tweetsodium ](https://github. com/github/tweetsodium ) library.
20657+ Encrypt your secret using the [libsodium-wrappers ](https://www.npmjs. com/package/libsodium-wrappers ) library.
2065820658
2065920659 ```
20660- const sodium = require('tweetsodium');
20661-
20662- const key = "base64-encoded-public-key";
20663- const value = "plain-text-secret";
20660+ const sodium = require('libsodium-wrappers')
20661+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
20662+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
2066420663
20665- // Convert the message and key to Uint8Array's (Buffer implements that interface)
20666- const messageBytes = Buffer.from(value);
20667- const keyBytes = Buffer.from(key, 'base64');
20664+ //Check if libsodium is ready and then proceed.
20665+ sodium.ready.then(() => {
20666+ // Convert Secret & Base64 key to Uint8Array.
20667+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
20668+ let binsec = sodium.from_string(secret)
2066820669
20669- // Encrypt using LibSodium.
20670- const encryptedBytes = sodium.seal(messageBytes, keyBytes);
20670+ // Encrypt the secret using LibSodium
20671+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
2067120672
20672- // Base64 the encrypted secret
20673- const encrypted = Buffer.from(encryptedBytes).toString('base64');
20673+ // Convert encrypted Uint8Array to Base64
20674+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
2067420675
20675- console.log(encrypted);
20676+ console.log(output)
20677+ });
2067620678 ```
2067720679
20678-
2067920680 #### Example of encrypting a secret using Python
2068020681
2068120682 Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3.
@@ -22710,28 +22711,29 @@ paths:
2271022711
2271122712 #### Example encrypting a secret using Node.js
2271222713
22713- Encrypt your secret using the [tweetsodium ](https://github. com/github/tweetsodium ) library.
22714+ Encrypt your secret using the [libsodium-wrappers ](https://www.npmjs. com/package/libsodium-wrappers ) library.
2271422715
2271522716 ```
22716- const sodium = require('tweetsodium');
22717-
22718- const key = "base64-encoded-public-key";
22719- const value = "plain-text-secret";
22717+ const sodium = require('libsodium-wrappers')
22718+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
22719+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
2272022720
22721- // Convert the message and key to Uint8Array's (Buffer implements that interface)
22722- const messageBytes = Buffer.from(value);
22723- const keyBytes = Buffer.from(key, 'base64');
22721+ //Check if libsodium is ready and then proceed.
22722+ sodium.ready.then(() => {
22723+ // Convert Secret & Base64 key to Uint8Array.
22724+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
22725+ let binsec = sodium.from_string(secret)
2272422726
22725- // Encrypt using LibSodium.
22726- const encryptedBytes = sodium.seal(messageBytes, keyBytes);
22727+ // Encrypt the secret using LibSodium
22728+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
2272722729
22728- // Base64 the encrypted secret
22729- const encrypted = Buffer.from(encryptedBytes).toString('base64');
22730+ // Convert encrypted Uint8Array to Base64
22731+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
2273022732
22731- console.log(encrypted);
22733+ console.log(output)
22734+ });
2273222735 ```
2273322736
22734-
2273522737 #### Example encrypting a secret using Python
2273622738
2273722739 Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3.
@@ -33466,28 +33468,29 @@ paths:
3346633468
3346733469 #### Example encrypting a secret using Node.js
3346833470
33469- Encrypt your secret using the [tweetsodium ](https://github. com/github/tweetsodium ) library.
33471+ Encrypt your secret using the [libsodium-wrappers ](https://www.npmjs. com/package/libsodium-wrappers ) library.
3347033472
3347133473 ```
33472- const sodium = require('tweetsodium');
33474+ const sodium = require('libsodium-wrappers')
33475+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
33476+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
3347333477
33474- const key = "base64-encoded-public-key";
33475- const value = "plain-text-secret";
33476-
33477- // Convert the message and key to Uint8Array's (Buffer implements that interface)
33478- const messageBytes = Buffer.from(value);
33479- const keyBytes = Buffer.from(key, 'base64');
33478+ //Check if libsodium is ready and then proceed.
33479+ sodium.ready.then(() => {
33480+ // Convert Secret & Base64 key to Uint8Array.
33481+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
33482+ let binsec = sodium.from_string(secret)
3348033483
33481- // Encrypt using LibSodium.
33482- const encryptedBytes = sodium.seal(messageBytes, keyBytes);
33484+ // Encrypt the secret using LibSodium
33485+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
3348333486
33484- // Base64 the encrypted secret
33485- const encrypted = Buffer.from(encryptedBytes).toString('base64');
33487+ // Convert encrypted Uint8Array to Base64
33488+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
3348633489
33487- console.log(encrypted);
33490+ console.log(output)
33491+ });
3348833492 ```
3348933493
33490-
3349133494 #### Example encrypting a secret using Python
3349233495
3349333496 Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3.
@@ -36254,28 +36257,29 @@ paths:
3625436257
3625536258 #### Example encrypting a secret using Node.js
3625636259
36257- Encrypt your secret using the [tweetsodium ](https://github. com/github/tweetsodium ) library.
36260+ Encrypt your secret using the [libsodium-wrappers ](https://www.npmjs. com/package/libsodium-wrappers ) library.
3625836261
3625936262 ```
36260- const sodium = require('tweetsodium');
36263+ const sodium = require('libsodium-wrappers')
36264+ const secret = 'plain-text-secret' // replace with the secret you want to encrypt
36265+ const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key
3626136266
36262- const key = "base64-encoded-public-key";
36263- const value = "plain-text-secret";
36264-
36265- // Convert the message and key to Uint8Array's (Buffer implements that interface)
36266- const messageBytes = Buffer.from(value);
36267- const keyBytes = Buffer.from(key, 'base64');
36267+ //Check if libsodium is ready and then proceed.
36268+ sodium.ready.then(() => {
36269+ // Convert Secret & Base64 key to Uint8Array.
36270+ let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
36271+ let binsec = sodium.from_string(secret)
3626836272
36269- // Encrypt using LibSodium.
36270- const encryptedBytes = sodium.seal(messageBytes, keyBytes);
36273+ // Encrypt the secret using LibSodium
36274+ let encBytes = sodium.crypto_box_seal(binsec, binkey)
3627136275
36272- // Base64 the encrypted secret
36273- const encrypted = Buffer.from(encryptedBytes).toString('base64');
36276+ // Convert encrypted Uint8Array to Base64
36277+ let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)
3627436278
36275- console.log(encrypted);
36279+ console.log(output)
36280+ });
3627636281 ```
3627736282
36278-
3627936283 #### Example encrypting a secret using Python
3628036284
3628136285 Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3.
0 commit comments