Jump to content

I am trying to write a program which encrypts  text by adding a number to each ascii value after it has been converted from string to an ASCII using a for loop and adding it to an array. after that i need the text to be encrypted (which i know is by adding a number to each value in the array using a for loop), and then converted back to characters and then back to a string. I have got so far in the encryption code):. how do i correct/finish the program to do this?

var

        s: string;
        asciivals: array [1..255] of byte;
        i: integer;
begin;
        write('Enter a string: '); readln(s);
        for i:=1 to length(s) do
                asciivals:=ord(s);
{ s accesses each element of the string as a char.
        ord returns the ASCII value of the char. }
        writeln('ASCII vals: ');
        for i:=1 to length(s) do
                writeln(asciivals);
        end.
end                    

Current Rig:   CPU: AMD 1950X @4Ghz. Cooler: Enermax Liqtech TR4 360. Motherboard:Asus Zenith Extreme. RAM: 8GB Crucial DDR4 3666. GPU: Reference GTX 970  SSD: 250GB Samsung 970 EVO.  HDD: Seagate Barracuda 7200.14 2TB. Case: Phanteks Enthoo Pro. PSU: Corsair RM1000X. OS: Windows 10 Pro UEFI mode  (installed on SSD)

Peripherals:  Display: Acer XB272 1080p 240Hz G Sync Keyboard: Corsair K95 RGB Brown Mouse: Logitech G502 RGB Headhet: Roccat XTD 5.1 analogue

Daily Devices:Sony Xperia XZ1 Compact and 128GB iPad Pro

Link to comment
https://linustechtips.com/topic/316798-lazarus-program-help/
Share on other sites

Link to post
Share on other sites

any help will be appreciated 

Current Rig:   CPU: AMD 1950X @4Ghz. Cooler: Enermax Liqtech TR4 360. Motherboard:Asus Zenith Extreme. RAM: 8GB Crucial DDR4 3666. GPU: Reference GTX 970  SSD: 250GB Samsung 970 EVO.  HDD: Seagate Barracuda 7200.14 2TB. Case: Phanteks Enthoo Pro. PSU: Corsair RM1000X. OS: Windows 10 Pro UEFI mode  (installed on SSD)

Peripherals:  Display: Acer XB272 1080p 240Hz G Sync Keyboard: Corsair K95 RGB Brown Mouse: Logitech G502 RGB Headhet: Roccat XTD 5.1 analogue

Daily Devices:Sony Xperia XZ1 Compact and 128GB iPad Pro

Link to comment
https://linustechtips.com/topic/316798-lazarus-program-help/#findComment-4306030
Share on other sites

Link to post
Share on other sites

First thing you need to do is add the encryption. You can either add it in when you store the ascii numbers in the array. Or you can add it as they are being used from the array. Then use the resulting values to build the string with the chr() function.

Link to comment
https://linustechtips.com/topic/316798-lazarus-program-help/#findComment-4306141
Share on other sites

Link to post
Share on other sites

i cant retrive their vaqlue from an array to check if they are between A to Z in the ascii numbers, how do i do this?

Current Rig:   CPU: AMD 1950X @4Ghz. Cooler: Enermax Liqtech TR4 360. Motherboard:Asus Zenith Extreme. RAM: 8GB Crucial DDR4 3666. GPU: Reference GTX 970  SSD: 250GB Samsung 970 EVO.  HDD: Seagate Barracuda 7200.14 2TB. Case: Phanteks Enthoo Pro. PSU: Corsair RM1000X. OS: Windows 10 Pro UEFI mode  (installed on SSD)

Peripherals:  Display: Acer XB272 1080p 240Hz G Sync Keyboard: Corsair K95 RGB Brown Mouse: Logitech G502 RGB Headhet: Roccat XTD 5.1 analogue

Daily Devices:Sony Xperia XZ1 Compact and 128GB iPad Pro

Link to comment
https://linustechtips.com/topic/316798-lazarus-program-help/#findComment-4310199
Share on other sites

Link to post
Share on other sites

i cant retrive their vaqlue from an array to check if they are between A to Z in the ascii numbers, how do i do this?

 

You're retrieving their values here

for i:=1 to length(s) do    writeln(asciivals[i]);

so instead of writing it to console, do the check and handle things appropriately.

Link to comment
https://linustechtips.com/topic/316798-lazarus-program-help/#findComment-4311523
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×