Shell Script - Coded Alphabet
Hi, everyone. :)
need help, I want to create a coded alphabet with specific values for each letter and character ex: # variables A="@_banana" a="99_Melon" B="81_GRAPE" b="22_strawberry" @="9_love" !="251_99" the script codes the sentence $ ./Encryptfruits -c "anything" the script decodes the sentence $ ./Encryptfruits -d "code" would anyone have any examples? I searched on google but found nothing Thank you all |
Welcome to LQ and the Programming forum!
Please place your code and data snippets inside [CODE]...[/CODE] tags for better readability. You may type those yourself or click the "#" button in the edit controls. The best way to obtain help from others is to show us what you have already done, and indicate what parts are giving you trouble. If this is a homework problem then you will only benefit if you try to work it out yourself. The problem as stated is not too difficult, and as it should be a shell script we may assume bash and I would suggest that you begin with bash arrays. The bash man page is an excellent resource for that, and you will find many online references, such as this, and the section on arrays here. See what you can figure out and let us know where you need help! Good luck! |
Not sure what this is for (just fun?), but you already know about rot13, right?
|
Quote:
Build a Pattern file of this form ... Code:
s/A/@_banana/g Code:
apple banana cherry Code:
sed -f $PatFile $InFile >$OutFile Code:
99_Melonpple 22_strawberry99_Melonn99_Melonn99_Melon cherry . |
This is also quite fast in perl. Build a table.
Code:
my %a = ( Code:
s/(.)/$a{$1}/eg; See "man perlre", "man perlretut", and "man perldata" for starters. What have you tried so far and where are you stuck? Post your code in whatever language between [code] ... [/code] tags and we'll be able to help. |
Code:
Code:
Output: @_banana !!_stars computer life_9900 I was wondering how do I do the reverse process ex: Code:
decode '@_banana !!_stars computer life_9900' Code:
Output: Abc! |
the revers process should do almost the same, just you need to use the decrypt array.
take first 8 chars, convert, remove from input and repeat. |
As some solutions have been provided, thought I would have a go in Ruby :)
Code:
#!/usr/bin/env ruby |
I need it to be in shell script, awk, perl, I don't know how to make the array identify one every 8 characters to crack the code
|
Quote:
|
so post what did you try and we can help you to correct it. How did you make what you posted in #6?
|
I'm trying
Code:
#! /bin/bash Code:
Output: i'm learning shell script, sorry for not understanding very well |
first, you need to keep the original crypt and decrypt arrays, that was ok, no need to change.
Code:
# to get the first 8 chars use: |
Quote:
Code:
1 #! /bin/bash |
Code:
#! /bin/bash |
All times are GMT -5. The time now is 12:56 PM. |