Sascha Schulz
2024-07-08 fc91ffd64c79a0fa8f35e7849e06fe2c825b8c81
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); // => &lt;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); // => &lt;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>