Sponsored Content
Top Forums Shell Programming and Scripting Problem of encrypt openssl RC4 Post 303024672 by Xremix30 on Sunday 14th of October 2018 12:56:31 PM
Old 10-14-2018
Problem of encrypt openssl with cypher RC4

Hi Guys sorry about post the code in portuguese but now i fix almost parts of code. now i can encryped and decryped the files but have a small problem. When not writte nathing generate automatically a random cypher but after the value of this cypher not appear igual than variable $saved_key. And used this value modifacate for decrypt file and i can see nathing because not use the correct cypher. How can fix this?

This my code modificate;

Code:
 

file_key="cypher.txt"
saved_key=$(cat cypher.txt)

menu_Start(){
clear_screen
echo ---------------------------------------------------
echo                  Manufactory RC4 OpenSSL
echo ---------------------------------------------------
echo ""
echo 1 - RC4 little used
echo Insert the cypher most be used:

read option_menu

case $option_menu in
1) menu;;
esac

}


menu(){
clear_screen

echo "REVERSE CRYPTO 4"
echo ""
echo "1 -> Encrypt"
echo "2 -> Decrypt"
echo "3 -> go back last menu"
echo "Choise the number of options:"

read option

case $option in
0);;	
1) encrypt_RC4 ;;
2) decrypt_RC4 ;;
esac
}

encrypt_RC4() {
clear_screen

name="RC4"
echo -n "Insert the cypher hex that you want created:"; read CYPHER
echo $CYPHER > $file_key

# Problem in this part when generated the cypher

if [[ -z "$CYPHER" ]]; then
echo $(openssl rand -hex 8) > $file_key # generated the cypher principal ex: abcdc34ba
fi
#--------------------------------------------------------------------------------------------------------
cat $file_key

echo -n "Insert the name of file for encrypted:"; read IN_FILE   
echo -n "Insert the name of file for out:"; read OUT_FILE
if [[ -z "$IN_FILE" ]]; then
   echo "The file was cypher"	
fi

case $option_menu in
1) algorithm_encryptRC4 ;;
esac

echo "The cypher used is: " $name
echo "The key of cypher is: " $saved_key # show other random cypher ex:abc45aec and used this value.
echo "The file created was:" $OUT_FILE
echo "The file exclued is:" $IN_FILE
}


decrypt_RC4() {
clear_screen

echo -n "Insert the name of the file encryped:"; read OUT_FILE
echo -n "Insert the name of the file for decrypting:"; read IN_FILE

if [[ -z "$OUT_FILE" ]]; then
	echo 
fi

case $option_menu in
1) algorithm_decryptRC4 ;;
esac


echo "The key used is: " $saved_key
echo "The file created was: " $IN_FILE
echo "The file exclued was: " $OUT_FILE	

}


algorithm_encryptRC4(){
openssl enc -rc4 -e -K "$saved_key" -in "$IN_FILE.txt" -out "$OUT_FILE.rc4"
}

algorithm_decryptRC4(){	
openssl enc -rc4 -d -K "$saved_key" -in "$OUT_FILE.rc4" -out "$IN_FILE.txt"
}

clear_screen(){
clear
}

menu_Start


Last edited by Xremix30; 10-15-2018 at 08:58 PM.. Reason: Because my code was Portuguese
 

5 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

solaris 9 openssl make problem with ld

i've seen a few posts regarding this issue, and i've tried the resolutions, but i keep running into the same problem. i'm trying to compile OpenSSL with the use of rsaref-2.0 (i'm running through this tutorial... (1 Reply)
Discussion started by: xyyz
1 Replies

2. Solaris

NRPE Compiling problem with OpenSSL 1.0

I am trying to compile nrpe 2.12 against openssl 1.0 on Solaris 10 however I am getting core dumps for some reason. Anyone know a way to fix this? Here is the output of make: bash-3.00# make all cd ./src/; make ; cd .. gcc -g -fPIC -Wall -O2 -I/usr/local/ssl/include... (0 Replies)
Discussion started by: _JPL_
0 Replies

3. UNIX for Dummies Questions & Answers

openssl dgst cat header problem

I am trying to run an old script to modify an image file with a modified header to bypass the md5 check but it comes up with an error message. The image file is for use on a Expressgate SSD so that I can add sqx files to it. This is a link from where I got the script:-... (3 Replies)
Discussion started by: r1speedyrider
3 Replies

4. Solaris

Solaris v Ubuntu using OpenSSL paste problem

Hello, I hope this means something to someone. I have an odd problem that just started happening recently. I am not the system admin, so I don't have full info on any changes to the system lately. Except that I did upgrade OpenSSL to version 1.0.1.c from 1.0.0j. Anyway, I am trying to... (4 Replies)
Discussion started by: jonycp
4 Replies

5. Shell Programming and Scripting

Openssl scripting problem

im trying to make sure the openssl password does not show up in the output of ps. so i'm trying to do something like this: MAST=yup echo "U2FsdGVkX19wH9LrQhuRZes45BM9rfiRpdhTCi+gLls=" | openssl <<HERE 2>&1 >/dev/null aes-128-cbc -a -d -salt -k "${MAST}" HERE But this isn't working.. I... (10 Replies)
Discussion started by: SkySmart
10 Replies
INTVAL(3)								 1								 INTVAL(3)

intval - Get the integer value of a variable

SYNOPSIS
int intval (mixed $var, [int $base = 10]) DESCRIPTION
Returns the integer value of $var, using the specified $base for the conversion (the default is base 10). intval(3) should not be used on objects, as doing so will emit an E_NOTICE level error and return 1. PARAMETERS
o $var - The scalar value being converted to an integer o $base - The base for the conversion Note If $base is 0, the base used is determined by the format of $var: o if string includes a "0x" (or "0X") prefix, the base is taken as 16 (hex); otherwise, o if string starts with "0", the base is taken as 8 (octal); otherwise, o the base is taken as 10 (decimal). RETURN VALUES
The integer value of $var on success, or 0 on failure. Empty arrays return 0, non-empty arrays return 1. The maximum value depends on the system. 32 bit systems have a maximum signed integer range of -2147483648 to 2147483647. So for example on such a system, intval('1000000000000') will return 2147483647. The maximum signed integer value for 64 bit systems is 9223372036854775807. Strings will most likely return 0 although this depends on the leftmost characters of the string. The common rules of integer casting apply. EXAMPLES
Example #1 intval(3) examples The following examples are based on a 32 bit system. <?php echo intval(42); // 42 echo intval(4.2); // 4 echo intval('42'); // 42 echo intval('+42'); // 42 echo intval('-42'); // -42 echo intval(042); // 34 echo intval('042'); // 42 echo intval(1e10); // 1410065408 echo intval('1e10'); // 1 echo intval(0x1A); // 26 echo intval(42000000); // 42000000 echo intval(420000000000000000000); // 0 echo intval('420000000000000000000'); // 2147483647 echo intval(42, 8); // 42 echo intval('42', 8); // 34 echo intval(array()); // 0 echo intval(array('foo', 'bar')); // 1 ?> NOTES
Note The $base parameter has no effect unless the $var parameter is a string. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.1.0 | | | | | | | Throws E_NOTICE and returns 1, when an object is | | | passed to $var. | | | | +--------+---------------------------------------------------+ SEE ALSO
boolval(3), floatval(3), strval(3), settype(3), is_numeric(3), Type juggling, BCMath Arbitrary Precision Mathematics Functions. PHP Documentation Group INTVAL(3)
All times are GMT -4. The time now is 10:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy