From fc91ffd64c79a0fa8f35e7849e06fe2c825b8c81 Mon Sep 17 00:00:00 2001
From: Sascha Schulz <sschulz@dh-software.de>
Date: Mo, 08 Jul 2024 16:18:21 +0200
Subject: [PATCH] add buffer section
---
index.html | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/index.html b/index.html
index a80829f..31beec7 100644
--- a/index.html
+++ b/index.html
@@ -4122,6 +4122,47 @@
</code>
</pre>
</section>
+ <section>
+ <h3>Buffer</h3>
+ <p>Array-artige Struktur für rohe Bytes</p>
+ <pre>
+ <code class="js" data-trim data-line-numbers>
+ const b1 = Buffer.from("abc"); // bevorzugt
+ const b2 = Buffer.alloc(100, 0); // Länge mit initialen Daten
+ const b3 = Buffer.allocUnsafe(100); // Länge ohne initiale Daten
+ const b4 = new Buffer("abc"); // offiziell nicht empfohlen
+
+ console.log(b1); // => <Buffer 61 62 63>
+ console.log(b1.toString("hex")); // => "616263"
+ </code>
+ </pre>
+ </section>
+ <section>
+ <p>Mit Buffern arbeiten:</p>
+ <pre>
+ <code class="js" data-trim data-line-numbers>
+ const a = Buffer.from("a") + Buffer.from("b");
+ const b = Buffer.concat([Buffer.from("a"), Buffer.from([98])]);
+ const c = b.toString()
+
+ console.log(a); // => ab
+ console.log(b); // => <Buffer 61 62>
+ console.log(c); // => ab
+
+ for (const byte of a) {
+ console.log(byte); // => 97 98
+ }
+ </code>
+ </pre>
+ </section>
+ <section>
+ <p>Aufgabe</p>
+ <p>Implementiere eine XOR-Verschlüsselung (<code>^</code>-Operator), sodass jedes Byte einer Original-Nachricht der Reihe nach mit dem entsprechenden Byte eines Schlüsselwortes verschlüsselt wird und gebe die verschlüsselte Nachricht als Text aus.</p>
+ </section>
+ <section>
+ <p>Aufgabe</p>
+ <p>Implementiere zur vorherigen Verschlüsselung eine Entschlüsselung.</p>
+ </section>
</section>
</div>
</div>
--
Gitblit v1.9.3