Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-12-2012, 01:29 AM   #1
LQ Newbie
Registered: May 2011
Posts: 3

Rep: Reputation: 0
Smile Ascii to Char and Char to Ascii conversion

I am completely new to Unix scripting with zero knowledge in it and have the below scenario can you please help me with the complete working script,

First script,

1. Get the string input from the user
2. Convert it to ASCII
3. Increment each character's ASCII value by 2. If the input value contains Y or Z it should be converted to A or B accordingly, same way the string may have special characters and numbers as well and they must be converted accordingly.
4. Form the new word
5. Store this in a file


Input : ABCD
Output : CDEF

and this output should be stored at the Value 1 location in a file like,

Value 1 : CDEF
Value 2 : XYX

This file will act as a config file and should be used in another script 2

Script 2 should read these values and before proceeding it should convert it back to original value (i.e. ABCD - should perform the reverse operation).

This is something like encrypting and decryption but its very primary. I am not worried about any security issues by achieving this logic as i am going to implement it on some log files with no value.

I am on solaris 5.10

Old 01-12-2012, 11:31 AM   #2
Registered: Sep 2008
Location: Ioannina, Greece
Distribution: Gentoo
Posts: 332

Rep: Reputation: 55
This looks like Ceasar cipher to me. Are you taking a computer security class? Well, I had this class but I worked on C, not script, where I just incremented the character by "key" (key is an integer). I believe you can do something similar in bash. Google for "Ceasar cipher in bash script".
Old 01-12-2012, 07:32 PM   #3
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,396

Rep: Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395
As he said, its a Caesar or 'rotation' cipher.
Which lang do you want; personally I'd use Perl.


ascii, char, conversion

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ascii to Char and Char to Ascii conversion rakesh.bharad Solaris / OpenSolaris 1 01-12-2012 06:54 AM
1 byte = 1 ASCII char? ghostdancer Programming 6 11-02-2007 08:42 PM
[C] char <=> ASCII-Code Cornholio Programming 7 03-06-2005 02:40 PM
sending extended ASCII char to serial fbarre Programming 4 04-20-2004 08:28 PM
ASCII char mapping tlennon Linux - Newbie 0 03-05-2001 07:10 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:29 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration