Write a program that reads and encrypts a text file Encrypti

Write a program that reads and encrypts a text file. Encryption is the science of hiding the contents of the file from users are not allowed to read its contents. Your program will firs read the data from a text file called data txt and save the information in an array of strings. The first line of the text file has an integer value that indicates the number of lines in the text file. This number will allow you to create a dynamic array of the correct number of strings, where each element in the array of strings will hold a single line of text. After the data is read and saved in the array, the next step is to encrypt the data. Modify the contents of the array by encryping its contents one element at a time. A very simple way of encrypting data is going though a string one character at a time, and adding 7 to the ASCII code of the character. After you are done with the text encryption, write the contents of the array in reverse order to a test file called encrypled.bd. For example, let us assume that the content of is the following

Solution

Encryption refers to the process of protecting data. Encryption is the transformation of intelligible data (plaintext) into an unintelligible form (ciphertext) by means of a mathematical process. The ciphertext is translated back to plaintext when the appropriate key that is necessary for decrypting (unlocking) the ciphertext is applied. There are two primary forms of encryption:

Read input from text file:

Set x=WScript.CreateObject(“WScript.shell”)

  entxtde=inputbox(“Enter text to be encoded”)

entxtde=StrReverse(entxtde)

x.Run “%windir%\ otepad”

wscript.sleep 1000

x.sendkeys encode(entxtde)

function encode(s)

For i=1 To Len(s)

newtxt=Mid(s,I,1)

newtxt=Chr(Asc(newtxt)+3)

coded=coded & newtxt

Next

encode=coded

End Function

Encrypts the array of strings:

var key=”0c9abc43b129a5a0c598b4752dAAAAAA”;

var iv=”655f42836f84b716e6e99cc982AAAAAA”;

var original_Text=”This is some text”;

var encrypted_Text=original_Text.encrypt_AES(key,iv);

var decrypted_Text=encrypted_Text.decrypt_AES(key,iv);

return @

original_Text:{0}

encrypted_TextL1)

decrypted_TextL2)*.format(original_Text,encrypted_Text.hexString(),decrypted_Text)

                                     .trim();

Encrypted data to output file:

       data grades(encrypt=aes encryptkey=ilovedata);

                 length Student $ 9;

                input Student $ StudentNumber section $

                                Test1 Test2 Final @ @;

                    format studentnumber z4.;

                  datalines;

 Write a program that reads and encrypts a text file. Encryption is the science of hiding the contents of the file from users are not allowed to read its conten
 Write a program that reads and encrypts a text file. Encryption is the science of hiding the contents of the file from users are not allowed to read its conten

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site