Page 1 of 3
simple encryption system
Posted: Sat Nov 02, 2013 2:29 pm
by tester
I'm looking for a simple encryption system for text data (letters, numbers, other characters, newline marks). I just need to convert some sort of "preset/project file" (i.e. text file, not used by preset manager - just loaded externally) into something not readable, and then back again. The only goal is to prevent user from accidental visual access to the content within that text file. Encrypted - would be meaningless enough.
Re: simple encryption system
Posted: Sat Nov 02, 2013 2:34 pm
by Tronic
base64, with some remix of string, should be good?
Re: simple encryption system
Posted: Sat Nov 02, 2013 2:47 pm
by tester
Anything that works correctly when converting back and forth, anything that makes the text meaningless if you open the text file, anything that works fast. Project files are small, few kB.
It should work correctly with multi-line texts; I noticed in some earlier posts, that there are some confusions on "end line" markings, depending on OS (and system settings?). The project itself uses green prims and ruby modules, so it could cause some problems.
Re: simple encryption system
Posted: Sat Nov 02, 2013 3:03 pm
by Tronic
the base 64, is not os dipendant.
Re: simple encryption system
Posted: Sat Nov 02, 2013 3:09 pm
by tester
If it's os independent, then it should be fine. As I mentioned - there is no big requirement for this encryption part.
Re: simple encryption system
Posted: Sat Nov 02, 2013 3:19 pm
by trogluddite
The CIA or a good hacker could crack this in a few minutes, but if you just want to obfuscate things enough to deter a casual onlooker, here's a quick encrypt/decrypt module...
Note that I haven't tested this when saving/loading the files, but values stay within the 8-bit ASCII range, so there shouldn't be a problem.
It also assumes that all input characters are "standard" ASCII - i.e. with codes within the 0-127 range, and no special "extended" characters. Again, that should be fine for regular text strings and numerals.
Encoding and decoding use exactly the same module with matching code key integers.
Re: simple encryption system
Posted: Sat Nov 02, 2013 3:28 pm
by tester
I use only letters (but will it work with non-english letters? we have a lot of ą, ę, ś, ż, and others, but different hanguages may have their own too), numbers, and some characters as a separators (,/\^| and few others).
Re: simple encryption system
Posted: Sat Nov 02, 2013 4:39 pm
by trogluddite
All of the separator characters should be OK, but at the moment, it won't work for non-english characters as they are outside the ASCII range.
Having said that, I'm not sure even how regular "green" strings would handle non-ASCII characters - it requires support for Unicode ("UTF"), which allows character codes longer than one byte. Ruby does have support for UTF, but whether it would interface well with "green", I do not know. The default encoding in Ruby is definitely just ASCII - presumably for compatibility with green strings.
Re: simple encryption system
Posted: Sat Nov 02, 2013 6:13 pm
by Tronic
the title is simple encryption system, and the base64 + mixin-string has all you need.
and support also the Unicode Char.
Re: simple encryption system
Posted: Sat Nov 02, 2013 6:45 pm
by tester
trogluddite wrote:All of the separator characters should be OK, but at the moment, it won't work for non-english characters as they are outside the ASCII range.
Having said that, I'm not sure even how regular "green" strings would handle non-ASCII characters - it requires support for Unicode ("UTF"), which allows character codes longer than one byte. Ruby does have support for UTF, but whether it would interface well with "green", I do not know. The default encoding in Ruby is definitely just ASCII - presumably for compatibility with green strings.
@Trog. To my surprise - both, green processing and ruby seem to work fine with our characters (it's based on Central European, either Windows 1250 or ISO-8859-2 coding). I'm using external text files, and have all language specific letters. But display may depend on operating system (enabled encodings). So it seems to be "pass through" situation.
@Tronic. Okay, where can i find it?