Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
package siber;
import java.util.Scanner;
public class Siber
{
/* encrypt and decrypt a text using a simple algorithm of metinting the letters */
static char[] chars = {
'a', 'b', 'c', 'ç', 'd', 'e', 'f', 'g', 'ğ', 'h',
'ı', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'ö', 'p',
'q', 'r', 's', 'ş', 't', 'u', 'ü', 'v', 'w', 'x',
'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'Ç', 'D', 'E', 'F', 'G',
'Ğ', 'H', 'I', 'İ', 'J', 'K', 'L', 'M', 'N', 'O',
'Ö', 'P', 'Q', 'R', 'S', 'Ş', 'T', 'U', 'Ü', 'V',
'W', 'X', 'Y', 'Z', '!', '@', '#', '$', '%', '^',
'&', '(', ')', '+', '-', '*', '/', '[', ']', '{',
'}', '=', '<', '>', '?', '_', '"', '.', ',', ' '
};
public static void main(String[] args)
{
/*String text = "abcç123";
int metin = 2;
String enc = encrypt(text, metin);
System.out.println("Encrypted text: " + enc);
String dec = decrypt(enc, metin);
System.out.println("Decrypted text: " + dec);
*/
int secim;
Scanner sc = new Scanner(System.in);
System.out.println("Metni Giriniz: ");
String text = new String();
text = sc.next();
System.out.println("Şifrele için 1 çöz için 2 girin");
secim = sc.nextInt();
switch (secim) {
case 1 :
int metin;
System.out.println("Anahtar Giriniz (Sayı): ");
metin = sc.nextInt();
String enc = encrypt(text, metin);
System.out.println(enc);
break;
case 2:
System.out.println("Anahtar Giriniz (Sayı): ");
int metin2 = sc.nextInt();
String dec = decrypt(text, metin2);
System.out.println(dec);
sc.close();
break;
}
}
// Caesar cipher
static String encrypt(String text, int metin)
{
char[] plain = text.toCharArray();
for (int i = 0; i < plain.length; i++) {
for (int j = 0; j < chars.length; j++) {
if (j <= chars.length - metin) {
if (plain[i] == chars[j]) {
plain[i] = chars[j + metin];
break;
}
}
else if (plain[i] == chars[j]) {
plain[i] = chars[j - (chars.length - metin + 1)];
}
}
}
return String.valueOf(plain);
}
static String decrypt(String cip, int metin2)
{
char[] cipher = cip.toCharArray();
for (int i = 0; i < cipher.length; i++) {
for (int j = 0; j < chars.length; j++) {
if (j >= metin2 && cipher[i] == chars[j]) {
cipher[i] = chars[j - metin2];
break;
}
if (cipher[i] == chars[j] && j < metin2) {
cipher[i] = chars[(chars.length - metin2 +1) + j];
break;
}
}
}
return String.valueOf(cipher);
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team