Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm having problems with encrypt/decrypt

Status
Not open for further replies.

chris86t

Technical User
Jun 13, 2008
41
US
I am trying to encrypt a string to a txt file and then decrypt it later. Usually it works, but sometimes I get the wrong characters back after decrypting. Any ideas why?
 
I did some playing with encrypt/decrypt in the past year (don't recall if it was here or via email) and came to the conclusion that it was broken as best I could tell.

 
Hmm, worked on this a bit more and seemed to be OK again, I love when that happens. Can you post your script? My guess is that your method of storing the string to a text file might not be preserving the string exactly, but just a guess at this point.

 
Well, I've been working on my own encryption function. Reguarding the question, I've tried several ways to write the data to files. It almost seems random what works and what doesn't. I'll post the script when I get back to it at work.
 
It has been years since I had this problem. Somebody gave me the fix which worked but I decided not to use encryption.
...but I think the decryption problem starts when the string to encrypt exceedes a certian length and the number of characters was odd (or maybe it was even).

I do not remember if it was the "set aspect datakey" command that fixed it.


Comments and code where I was encrypting/decrypting:
===================================================
;...does not work for a string containing three pairs
;of userIDs and Passwords.
;Will "set aspect datakey" fix it?"

;strlen PWcrypt Len
;usermsg "length: %d" len
;encrypt PWcrypt Len


Here is the command description:
===============================
aspect datakey integer

Specifies the integer key used in the encrypt and decrypt commands. fetch returns the value of the current integer key.
For more information on the use of the datakey in encryption, see the encrypt command and the decrypt command.

The datakey value must be equal to the value used to encrypt the string to properly decrypt the string. It can be set with the set aspect datakey command."


This is from the help file:
==========================
"Use caution if writing the encrypted data to a text file. Since the data may contain control characters or even nulls, it is not suitable for a Windows .ini file."



 
...the length and character count (even or odd) I mentioned above might explain why it is random.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top