Sorry about the long posts.
The first few characters look the same because each line is prefixed with a random salt that starts with the word "Salted__" followed by eight bytes of salt data.
The reason you do not need an equal sign with /var is because it is optional, for historical reasons. However, you should use the equal sign as it makes it clear to the parser, and to yourself when you read through your code, where the assignment value begins.
Khaled: I actually did use the equals sign originally in my script but when I did, it became part of the string so I had to take it out. You can see what I mean if you put it in and run it. It's like mIRC isn't parsing it right. Or more likely it might be my script since, I just started learning two days ago.
Also does the default padding for the cipher use the type of padding where the value of each added byte is the number of bytes that are added or is the default padding zero filled etc... I think the default for PKCS5, Blowfish is where each padding byte is the value of the number of padding bytes added.
One last and hopefully final question. Should I be salting the message for the added security?
Thank you so much.
When I put the equal signs in the 3 spots where they should be in the script, it outputs this. The first equals sign in each message should not be there and it also garbles the decrypted messages.
Original message is
= AMDAPPSDKROOT = C:\Program Files (x86)\AMD APP\
Original message is
= ALLUSERSPROFILE = C:\ProgramData
Encrypted message is
= H4V%L=&5D7U__]8Y=Q*N6X8;9$T=7WT\]5#(?H@#2TGD8I07L03N6:@``
Encrypted message is
= H4V%L=&5D7U]E1=R1?LP8-KNUY+IODSI5H@340J-RBS3?]P)T;XL&L0``
Decrypted message is
= ³ðl“ö¬«ýTÏt‚ÂI½S¦Žއ84dé;ڔ×y5ì½%e±%íò>$•Õí…rûÂ
Decrypted message is
= ‹>ìà›…~¼—"~NÏí
My current script as of December 1, 2014 8:14pm CST
I can't use the forum's 'code' section for my script because it won't highlight my trouble areas. Sorry./encrypt {
; Clear the active window.
clear
; Check to make sure mIRC is version 7.38 or later so I can use $envvar to populate the message array.
If ($version < 7.38) {
echo -a mIRC v7.38 or later is required. This script uses '$envvar' to populate the message array, which is only available in mIRC v7.38 and later.
halt
}
; Use Windows environment variables as test data for my message encryption script.
; Declare variable %i and assign $envvar(0) (which returns the total amount of Windows OS environment variables) to %i.
var %i = $envvar(0)
; Create a variable array by using the '$+' concatenation operator to append a number (string) to
; the end of each variable as it is declared while also assigning to it the environment name and value
; together as one long string. Not sure why I don't need to use the '=' in between [ $+ [ %i ] ] and $envvar(%i).name.
while (%i >= 1) {
var %message.original. [ $+ [ %i ] ] $envvar(%i).name $+ $chr(32) $+ $chr(61) $+ $chr(32) $+ $envvar(%i).value ; Echo %message.original. array to the active window.
echo -a Original message is %message.original. [ $+ [ %i ] ]
dec %i
}
; Reset %i to $envvar(0).
%i = $envvar(0)
; %encryption.key MUST be 56 bytes (448 bits) long. Encryption type is Blowfish. http://en.wikipedia.org/wiki/Blowfish_(cipher)
var %encryption.key = hfudnqtwh5jv748djne219fndjem568djsmrmufiuhuihgf789yqnkdg
; Encrypt %message.original. array and assign output to %message.encrypted. array.
while (%i >= 1) {
var %message.encrypted. [ $+ [ %i ] ] $encode(%message.original. [ $+ [ %i ] ],cl,%encryption.key) ; Echo %message.encrypted. array to the active window.
echo -a Encrypted message is %message.encrypted. [ $+ [ %i ] ]
dec %i
}
; Reset %i to $envvar(0).
%i = $envvar(0)
; Change the encryption key to see if it garbles the ouput.
; Should not decrypt properly if the %encryption.key variable is changed before decrypting below.
; %encryption.key MUST be 56 bytes (448 bits) long. Encryption type is Blowfish. http://en.wikipedia.org/wiki/Blowfish_(cipher)
%encryption.key = hfudnqtwh5jv748djne219fndjem568djsmrmufiuhuihgf789yqnkdg
while (%i >= 1) {
var %message.decrypted. [ $+ [ %i ] ] $decode(%message.encrypted. [ $+ [ %i ] ],cl,%encryption.key) ; Echo %message.decrypted. array to the active window.
echo -a Decrypted message is %message.decrypted. [ $+ [ %i ] ]
dec %i
}
}