Amaliy ishi 1 bajardi: Odinayev Ilhom tekshirdi: Olimov Iskandar Toshkent-2022 Mavzu



Download 188,46 Kb.
Sana14.04.2022
Hajmi188,46 Kb.
#550017
Bog'liq
Odinayev Ilhom 1-amaliy


O’ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI

Dasturiy vositalar xavfsizligi


AMALIY ISHI - 1

BAJARDI: Odinayev Ilhom


TEKSHIRDI: Olimov Iskandar

Toshkent-2022


Mavzu: Dasturiy vositalarni ishlab chiqarishning hayotiy siklini amaliy tadbiqi

Dasturiy kodi:


package com.company;

import java.io.File;


import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Base64;
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
// write your code here
String path = "C:\\Users\\Acer\\Desktop\\Odinayev.I.txt";
createFile(path);
writeToFile(path);
readToFile(path);
}

private static void createFile(String path) {


try {
File myObj = new File(path);
if (myObj.createNewFile()) {
System.out.println("File created: " + myObj.getName());
} else {
System.out.println("File already exists.");
}
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
public static void writeToFile(String path) {
try {
FileWriter myWriter = new FileWriter(path);
Scanner scanner = new Scanner(System.in);
System.out.print("Name: ");
String name = scanner.nextLine();
System.out.print("Surname: ");
String surname = scanner.nextLine();
System.out.print("Group: ");
String group = scanner.nextLine();
System.out.print("Age: ");
String age = scanner.nextLine();
String str = "Name: " + name + "\n" + "Surname: " + surname + "\n" + "Group: " + group + "\n" + "Age:" + age;
String encrypt = Base64.getEncoder().encodeToString(str.getBytes());
myWriter.write(encrypt);
myWriter.close();
System.out.println("Successfully wrote to the file.");
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}

public static void readToFile(String path) {


try {
File myObj = new File(path);
Scanner myReader = new Scanner(myObj);
while (myReader.hasNextLine()) {
String data = myReader.nextLine();
System.out.println("Encrypt data: " + data);
byte[] decodedBytes = Base64.getDecoder().decode(data);
String decodedString = new String(decodedBytes);
System.out.println(decodedString);
}
myReader.close();
} catch (FileNotFoundException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
}

Natija :


Faylda shifrlangan ma’lumotlar:

Download 188,46 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