Sponsored Content
Full Discussion: Data Encryption
Top Forums Shell Programming and Scripting Data Encryption Post 302953927 by MadeInGermany on Wednesday 2nd of September 2015 04:15:46 PM
Old 09-02-2015
Comments on the the previous solution:
The split() and the following loop are static; it is more efficient to place them in the BEGIN section.
And in the main section it is better to initialize a loop variable (use a for loop!), in case there is more than one line.
The split( , , "") is not understood by all awk versions, others might need
Code:
lenA=split("a b c d e f g ...", A)

--
Here is a solution with a string
Code:
 cat file
abc1,abc2,abc3,abc4

Code:
 cat crypt3.sh
awk -F, -v OFS=, '
BEGIN {
  chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  lchars=length(chars)
}
function crypt(s) {
  s1=""
  for (pos=1; pos<=length(s); pos++) {
    c=substr(s,pos,1)
    i=index(chars,c)
    c1=substr(chars,1+(1+i)%lchars,1)
    s1=s1 (i>0 ? c1 : c)
  }
  return s1
}
{
  $3=crypt($3)
  print
}
' "$@"

Code:
 sh crypt3.sh file
abc1,abc2,cde3,abc4


Last edited by MadeInGermany; 09-02-2015 at 05:28 PM.. Reason: retain characters that do not match
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

which encryption method?

hello ppl, i've been coding a perl script for xchat and i need to store the nick's passwords. i was wondering which encryption to use. picture this situation: i've got a system flaw and some guy hacks the machine and gets his hands on the passwd file; he has access to the script. what encryption... (2 Replies)
Discussion started by: crashnburn
2 Replies

2. Shell Programming and Scripting

encryption is possible??

NEED expertise help for this topic!!! Question 1: Is encryption possible for the shell scriping programing? shadow the scriping file, do think is impossible... Question2: built a simple program with the simplicity function that allow user change settings by enter corret name and... (3 Replies)
Discussion started by: trynew
3 Replies

3. UNIX for Dummies Questions & Answers

File encryption/Key encryption ????

My dilemma, I need to send, deemed confidential, information via e-mail (SMTP). This information is sitting as a file on AIX. Typically I can send this data as a e-mail attachment via what we term a "mail filter" using telnet. I now would like to somehow encrypt the data and send it to a e-mail... (1 Reply)
Discussion started by: hugow
1 Replies

4. IP Networking

no encryption type specified

Hi I have created a user in snmpv3 as myuser n gave a password. Its also feching data by snmpget. Then I created another user as arika and the password is same as myuser.. Now I am trying to change the password by the command : snmpusm -v 3 -u arika -l authNoPriv -a MD5 -A my_password... (1 Reply)
Discussion started by: swapna_me
1 Replies

5. UNIX for Dummies Questions & Answers

Password encryption

In unix, i know the password encrypt by using salt But how does it work? And how windows protect its password? Thank you for helping in advance (5 Replies)
Discussion started by: cryogen
5 Replies

6. Cybersecurity

File encryption tools with MAC address as an encryption key

Hi all, I'm looking for secure file encryption tools that use MAC address as encryption key. FYI, I'm using Red Hat Enterprise Linux OS. For example: when A wants to send file to B A will encrypt the file with B's computer MAC/IP address as an encryption key This file can only be decrypted... (2 Replies)
Discussion started by: sergionicosta
2 Replies

7. Solaris

Vormetric Data Encryption on Solaris Redhat

Does anyone have experience running the Vormetric Data Encryption on Oracle Solaris platform? (0 Replies)
Discussion started by: dwevans
0 Replies

8. Solaris

Zfs send & receive with encryption - how to retrieve data?

Good morning everyone, I'm looking for some help to retrieve data in a scenario where I might have made a big mistake. I'm hoping to understand what I did wrong. My system is made of two Solaris 11 Express servers (old free version for evaluation). The first if for data and the second is... (7 Replies)
Discussion started by: rnd
7 Replies
REPLACE(1)						      General Commands Manual							REPLACE(1)

NAME
replace - A utility program that is used by msql2mysql, but that has more general applicability as well. replace changes strings in place in files or on the standard input. Uses a finite state machine to match longer strings first. Can be used to swap strings. USAGE
replace [-?svIV] from to from to ... -- [files] or replace [-?svIV] from to from to ... < fromfile > tofile SYNOPSIS
replace [-?|-I] [-s] [-v] DESCRIPTION
replace -?|-I info -s silent -v verbose EXTRA INFO
Special characters in from string: ^ Match start of line. $ Match end of line.  Match space-character, start of line or end of line. For a end  the next replace starts locking at the end space-character. A  alone in a string matches only a space-character. EXAMPLE
this command swaps a and b in the given files: shell> replace a b b a -- file1 file2 ... SEE ALSO
isamchk (1), isamlog (1), mysqlaccess (1), mysqladmin (1), mysqlbug (1), mysqld (1), mysqldump (1), mysqlshow (1), msql2mysql (1), perror (1), replace (1), safe_mysqld (1), which1 (1), zap (1), AUTHOR
Ver 1.0, distribution 3.23.29a Michael (Monty) Widenius (monty@tcx.se), TCX Datakonsult AB (http://www.tcx.se). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill-9.dk), Mercurmedia Data Model Architect / system developer (http://www.mer- curmedia.com) 20 December 2000 REPLACE(1)
All times are GMT -4. The time now is 04:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy