Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Byte in char umwandeln

Empfohlene Antworten

Veröffentlicht

Ich speichere ein Passwort in einer Textdatei, damit das Passwort nicht durch einfaches öffnen ersichtlich sein sollte, wollte ich das ganze etwas verschlüsseln.

Also hab ich mir überlegt auf jedes byte des Passwortes einfach eine zahl drauf zu addieren.

Das Problem ist jetz aber, dass wenn das "verschlüsselte" byte nicht in einem bestimmten Wertebereich(ich nehm ma 32-126 an) liegt, dann kommt nur noch Unsinn dabei raus.

Wird wohl am Charset liegen nehm ich an.

Jetzt weiss ich nicht so recht wie ich das Problem lösen soll.


        byte[] temp = Daten[i][x].getBytes();

	for(int y = 0; y < Daten[i][x].length() ; y++)

	{

	       temp[y] = (byte) (temp[y] + CODE);

	}

	Daten[i][x] = "";

	for(int z = 0; z < temp.length; z++) 

       {

	       Daten[i][x] += (char)temp[z];

	}

Daten[][] ist ein String-Array

CODE ist die Konstante die auf das Byte addiert wird. z.b. 100

Wenn jemand eine Idee hat wie ich ab 126 einen Überlauf auf 32 erzeuge, dann würde mir das auch reichen ^^

Bearbeitet von ShamaN

Der Modulo-Operator "%" dürfte dir helfen.

z.B.

temp[y] = (byte) (temp[y] + CODE)%(MAX+1)+MIN;

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.