LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 01-12-2012, 01:29 AM   #1
rakesh.bharad
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

Eg.

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

Thanks
Rakesh
 
Old 01-12-2012, 11:31 AM   #2
segmentation_fault
Member
 
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
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

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


Reply

Tags
ascii, char, conversion



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:08 AM.

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