Sascha Schulz
2024-09-16 e3de9fd281958e70d1801c2c3681634933b8e932
add examples for crypto and zlib
3 Dateien hinzugefügt
29 ■■■■■ Geänderte Dateien
templates/010-nodejs/crypto.js 3 ●●●●● Patch | Ansicht | Raw | Blame | Historie
templates/010-nodejs/text-examples.txt 2 ●●●●● Patch | Ansicht | Raw | Blame | Historie
templates/010-nodejs/zlib.js 24 ●●●●● Patch | Ansicht | Raw | Blame | Historie
templates/010-nodejs/crypto.js
Neue Datei
@@ -0,0 +1,3 @@
const crypto = require("crypto");
const hash = cryptop.createHash(/* algorythm */); // "md5", "sha256"
templates/010-nodejs/text-examples.txt
Neue Datei
@@ -0,0 +1,2 @@
TEXTCOLLBYfGiJUETHQ4hAcKSMd5zYpgqf1YRDhkmxHkhPWptrkoyz28wnI9V0aHeAuaKnak
TEXTCOLLBYfGiJUETHQ4hEcKSMd5zYpgqf1YRDhkmxHkhPWptrkoyz28wnI9V0aHeAuaKnak
templates/010-nodejs/zlib.js
Neue Datei
@@ -0,0 +1,24 @@
const zlib = require("zlib");
const { pipeline } = require("stream");
// Komprimieren
zlib.deflate("abc" /* buffer | string */, (err, compressed) => {
});
// Dekomprimieren
zlib.inflate(compressed /* buffer */, (err, decompressed) => {
});
// Als Stream
const zipper = zlib.createDeflate();
const unzipper = zlib.createInflate();
source.pipe(zipper).pipe(target);
source.pipe(unzipper).pipe(target);
// einfachere Alternative
pipeline(source, zipper, target, (err) => {
    console.error(err);
});