Package com company; import java util. Scanner; public class Main { public static void



Download 65,26 Kb.
Sana30.12.2021
Hajmi65,26 Kb.
#90209
Bog'liq
SIROJ3labkribtografiya


Sezar shifrlash usuli Java dasturlash tilida

package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner km= new Scanner(System.in);
System.out.print("matnni kiriting=");
String matn1 = km.nextLine();
System.out.print("KALIT(alifboni surishsoni)=");
int surishsoni1 = km.nextInt();
String shifrmatn = "";
char alifboharfi;
for(int i=0; i < matn1.length();i++)
{ alifboharfi = matn1.charAt(i);
//agar harfimiz kichik harf bo'lsa
if(alifboharfi >= 'a' && alifboharfi <= 'z')
{ alifboharfi = (char) (alifboharfi + surishsoni1);
if(alifboharfi > 'z') { alifboharfi = (char) (alifboharfi+'a'-'z'-1);}
shifrmatn =shifrmatn + alifboharfi;}
//Agar harfimiz katta harf bo'lsa
else if(alifboharfi >= 'A' && alifboharfi <= 'Z') { alifboharfi = (char) (alifboharfi + surishsoni1);
if(alifboharfi > 'Z') {alifboharfi = (char) (alifboharfi+'A'-'Z'-1);}
shifrmatn = shifrmatn + alifboharfi; }
else {shifrmatn = shifrmatn + alifboharfi;}}
System.out.println("Shifrmatn : " + shifrmatn);
}}

Dastur natijasi:



Vernam shifrlash usuli Java dasturlash tilida



package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner km = new Scanner(System.in);
System.out.print("textni kiriting = ");
String text = km.nextLine();
char textmassiv[] = text.toCharArray();
System.out.print("kalitni kiriting = ");
String kalit = km.nextLine();
char kalitmassiv[] = kalit.toCharArray();
char[] shifrtext = new char[text.length()];
System.out.println("textimiz => " + text + " => Uzunligi=" + text.length()+" ga teng");
if (text.length() < kalit.length()) {
String C = "";
for (int i = 0;ikalit = C;}
int j = kalit.length();
while (kalit.length() < text.length()) {
for (int i = 0; i < j; i++) {
kalit = kalit + kalitmassiv[i];
if (kalit.length() == text.length()) break;}}
System.out.println("kalitimiz => " + kalit + " => Uzunligi=" + kalit.length()+" ga teng");
char kalitoxirginatijasi[] = kalit.toCharArray();
System.out.print("shifrtextimiz => ");
for (int i = 0; i < textmassiv.length; i++) {
shifrtext[i] = (char) (textmassiv[i] ^ kalitoxirginatijasi[i]);
System.out.print(shifrtext[i]);}
System.out.print(" => Uzunligi="+shifrtext.length+" ga teng");
}}

Dastur natijasi:



Vijiner shifrlash usuli Java dasturlash tilida



package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
char alifbo[]=new char[26], kalif[]=new char[26];
for (char i=0,j= 'A'; j<='Z' ; i++,j++) {
alifbo[i]=j; }
Scanner x=new Scanner(System.in);
String kalit, ochmatn;
System.out.print("kodlanadigon matnni kiriting ");
ochmatn=x.nextLine();
System.out.print("kalitni kiriting ");
kalit=x.nextLine();
char kt[]=kalit.toCharArray(), ochm[]=ochmatn.toCharArray(),
um[]=new char[ochmatn.length()], kmatn[]=new char[ochmatn.length()];
for (char j=0,i = 0; i length ;j++, i++) {
um[i]=kt[(j+kt.length)%kt.length]; }
for (char i = 0; i length ; i++)
for (char j = 0; j length ; j++) {
if (um[i]==alifbo[j]){
for (char l=j, k = 0; k length ;l++, k++) {
kalif[k]=alifbo[l%26]; }
for (int k = 0; k length ; k++)
for (int l = 0; l < alifbo.length; l++) {
if (ochm[i]==alifbo[l]){
kmatn[i]=kalif[l]; } }}}
System.out.print(" Shifrmatn = ");
for (int i = 0; i length ; i++) {
System.out.print(kmatn[i]);
}

}}

DASTUR NATIJASI:




Download 65,26 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish