very simple encryption

A

angelochen960

Hi,
I just need a simple way to encrypt/decrypt a string, main purpose is,
making it not readable by human eye, any hints on this? thanks,
Angelo
 
M

Mike Schilling

Hi,
I just need a simple way to encrypt/decrypt a string, main purpose is,
making it not readable by human eye, any hints on this? thanks,

Hint:

Each character in the String is a number (unsigned 16-bit integer, to be
specific.) If you do some bit of arithmetic to it that you can easily undo,
that gives you encryption and decryption.
 
K

Knute Johnson

Hi,
I just need a simple way to encrypt/decrypt a string, main purpose is,
making it not readable by human eye, any hints on this? thanks,
Angelo

import java.nio.charset.*;

public class test {
public static void main(String[] args) throws Exception {
String str = "Now is the time for all good men to come...";

System.out.println(str);

byte[] buf = encode(str);

System.out.println(new String(buf,"US-ASCII"));

str = decode(buf);

System.out.println(str);
}

static byte[] encode(String str) throws Exception {
byte[] buf = str.getBytes("US-ASCII");
for (int i=0; i<buf.length; i++)
buf ^= 64;

return buf;
}

static String decode(byte[] buf) throws Exception {
for (int i=0; i<buf.length; i++)
buf ^= 64;
return new String(buf,"US-ASCII");
}
}

C:\Documents and Settings\Knute Johnson>java test
Now is the time for all good men to come...
♫/7`)3`4(%`4)-%`&/2`!,,`'//$`-%.`4/`#/-%nnn
Now is the time for all good men to come...

You could rotate the XOR'd bit and make it even more complicated. I
don't know if it is still the case, but the LAPD used a similar
technique to obfuscate their in car terminal data stream.
 
J

Joshua Cranmer

Hi,
I just need a simple way to encrypt/decrypt a string, main purpose is,
making it not readable by human eye, any hints on this? thanks,
Angelo

Look for something called `base64.' It has the bonus of consisting
entirely of characters from the sets A-Z, a-z, 0-9, +, /, and = (or
occasionally some other special characters).
 
D

David Segall

Hi,
I just need a simple way to encrypt/decrypt a string, main purpose is,
making it not readable by human eye, any hints on this? thanks,
Angelo

The easiest way is to exclusive or each character in the string with a
constant. This has the magical property that the same code can be used
to encrypt and decrypt the string.
 
R

Roedy Green

Hi,
I just need a simple way to encrypt/decrypt a string, main purpose is,
making it not readable by human eye, any hints on this? thanks,
Angelo

For code that does not use the JCE, see
http://mindprod.com/products1.html#TRANSPORTER

for JCE code, see samples at
http://mindprod.com/jgloss/jce.html

If you want something very simple, there is ROT13, xor with a key, xor
with a string of "random" numbers starting with a seed.
--
Roedy Green Canadian Mind Products
http://mindprod.com

One path leads to despair and utter hopelessness. The other,
to total extinction. Let us pray we have the wisdom to choose correctly.
~ Woody Allen .
 
B

Bent C Dalager

With Java you can easily achieve this by using the regular encryption
library with a well known key (that is, one hard-coded into the
application). Googling "java aes encryption" should give plenty of
code samples.
The usual term for this is "obfuscation"

This is important to keep in mind. Even though the above approach uses
encryption algorithms you shouldn't pretend that you're actually
encrypting the content because encryption with a well-known key, well,
isn't.

Cheers,
Bent D
 
D

David Zimmerman

rossum said:
On Mon, 23 Feb 2009 16:13:30 -0800 (PST), "(e-mail address removed)"

If Aunt Agatha runs the NSA, GCHQ or equivalent then you have a very
difficult problem indeed.

Your Aunt Agatha is way cool
 
J

John B. Matthews

Mark Space said:
And wears a lot of hats.

Suspecting that her cover is blown, she may offer you a glass of
home-made elderberry wine. Decline, politely but firmly.
 
B

blue indigo

<pan.2009.02.26.15.58.42.312500@uatel.com.nospam.bogus.invalid.invalid.i
nvalid>,
blue indigo


Oh, say they're not censoring your access to Monty Python's Hell's
Grannies!

Naw, I got YouTube's idea of a 404 page, a black box saying no such video
or someat, not a host unknown or unreachable or timeout error.
 
B

Bjorn Borud

["(e-mail address removed)" <[email protected]>]
| Hi,
| I just need a simple way to encrypt/decrypt a string, main purpose is,
| making it not readable by human eye, any hints on this? thanks,

if you just want to obfuscate it so the string can't be read casually,
base64-encoding it should do.

-Bjørn
 
M

Martin Gregorie

["(e-mail address removed)" <[email protected]>] | Hi,
| I just need a simple way to encrypt/decrypt a string, main purpose is,
| making it not readable by human eye, any hints on this? thanks,

if you just want to obfuscate it so the string can't be read casually,
base64-encoding it should do.
So would using a hexadecimal representation of each byte.
 
M

Mike Schilling

Martin said:
I just need a simple way to encrypt/decrypt a string, main purpose
is, making it not readable by human eye, any hints on this? thanks,

if you just want to obfuscate it so the string can't be read
casually, base64-encoding it should do.
So would using a hexadecimal representation of each byte.

I can read that without too much trouble; I don't think I'm alone. A
simple, reversible, and undocumented bit of arithmetic (say, XORing with
some randomly chosen 16-bit quantity) would obfuscate things much more
effectively. If you need the result to be ASCII, then base64 or hexadecimal
on the result would work fine for that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top