By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,742 Members | 793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,742 IT Pros & Developers. It's quick & easy.

Simple Encryption of text string

P: n/a

Hi,
Does anyone have any simple text string encryption routines that are
easy to implement? I'm trying to prevent users and system
administrators from figuring out how I implement things.
thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
guy
try exclusive oring each byte of a string with a value e.g.7
to decrypt repeat the procedure
this is very simple and not dificult to break, but might do what you wan

hth guy
Nov 20 '05 #2

P: n/a

HOW do you do it? Do you have the code that will do it?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3

P: n/a
guy
I havent tested it but something like this..

dim start as string="Beginning
dim finish as string="
dim i as intege
dim mask as integer= 78 ' or whateve
for i = 1 to len(start
finish = finish & chrw(ascw(mid(start,i,1)) xor mask
next

to decrypt just do the same thing on finish and you will get start bac

hth gu

----- larry mckay wrote: ----
HOW do you do it? Do you have the code that will do it
*** Sent via Developersdex http://www.developersdex.com **
Don't just participate in USENET...get rewarded for it

Nov 20 '05 #4

P: n/a
guy
oops! dont use 78 use something like &H9bb9 to cos unicode is 16 bit
Nov 20 '05 #5

P: n/a
* larry mckay <la***@larrymckay.com> scripsit:
Does anyone have any simple text string encryption routines that are
easy to implement? I'm trying to prevent users and system
administrators from figuring out how I implement things.


For example, in C#:

<URL:http://www.google.de/groups?selm=ePU4xOBVCHA.1644%40tkmsftngp08>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6

P: n/a
First of all, and sorry Guy, I don't mean to pick on ya, I know you're
trying to help :-) but if data is worth encrypting, NEVER, EVER use
encoding and don't make up your own encryption schemes. There's a HUGE
security difference between encoding (simple shifting of text data in
predictable ways) and standard encryption.

Luckily, the .NET framework has a bunch of encryption stuff built in that
you can use.
Try this code out, and post any questions you may have about it (I wrote
this in a windows form):

Function Encrypt(ByVal plainText As String, ByVal key As Byte(), ByVal iv As
Byte()) As String
Dim cipher As New RijndaelManaged
Dim encryptor As ICryptoTransform = cipher.CreateEncryptor(key, iv)
Dim data As Byte() = Encoding.Unicode.GetBytes(plainText)
Return Convert.ToBase64String(encryptor.TransformFinalBlo ck(data, 0,
data.Length))
End Function

Function Decrypt(ByVal encryptedText As String, ByVal key As Byte(), ByVal
iv As Byte()) As String
Dim cipher As New RijndaelManaged
Dim decryptor As ICryptoTransform = cipher.CreateDecryptor(key, iv)
Dim data As Byte() = Convert.FromBase64String(encryptedText)
Return Encoding.Unicode.GetString(decryptor.TransformFina lBlock(data, 0,
data.Length))
End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim key As Byte() = {170, 56, 39, 124, 31, 136, 211, 100, 180, 51, 111,
88, 217, 92, 214, 36, 164, 188, 71, 51, 36, 187, 195, 205, 87, 167, 81, 248,
173, 7, 194, 10}
Dim iv As Byte() = {33, 162, 253, 195, 255, 140, 120, 198, 25, 99, 222,
141, 182, 152, 94, 28}

Dim plainText As String = "This is a test"
Dim encryptedText As String

encryptedText = Encrypt(plainText, key, iv)
MsgBox(encryptedText)
plainText = ""
plainText = Decrypt(encryptedText, key, iv)
MsgBox(plainText)

End Sub

Of course, you'll want to create your own key and IV values. You must use
the same key (and IV) to decrypt a value as the key (and IV) that was used
to encrypt it. Other keys will not work, and will just cause an error, or
return garbage. If you use the Rijndael encryption algorithm (like i did
here), the key should be 32 bytes in length, and the IV 16 bytes.

-Rob Teixeira [MVP]
"larry mckay" <la***@larrymckay.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...

Hi,
Does anyone have any simple text string encryption routines that are
easy to implement? I'm trying to prevent users and system
administrators from figuring out how I implement things.
thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.