472,141 Members | 1,102 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,141 software developers and data experts.

Simple Encryption of text string


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
6 7701
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

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
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
guy
oops! dont use 78 use something like &H9bb9 to cos unicode is 16 bit
Nov 20 '05 #5
* 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
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.

Similar topics

5 posts views Thread by c duden | last post: by
11 posts views Thread by Beeeeeeeeeeeeves | last post: by
3 posts views Thread by Anon | last post: by
11 posts views Thread by John Williams | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.