473,554 Members | 2,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7849
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="Beginni ng
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(s tart,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***@larrymck ay.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=ePU 4xOBVCHA.1644%4 0tkmsftngp08>

--
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 ICryptoTransfor m = cipher.CreateEn cryptor(key, iv)
Dim data As Byte() = Encoding.Unicod e.GetBytes(plai nText)
Return Convert.ToBase6 4String(encrypt or.TransformFin alBlock(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 ICryptoTransfor m = cipher.CreateDe cryptor(key, iv)
Dim data As Byte() = Convert.FromBas e64String(encry ptedText)
Return Encoding.Unicod e.GetString(dec ryptor.Transfor mFinalBlock(dat a, 0,
data.Length))
End Function

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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(plainTe xt, key, iv)
MsgBox(encrypte dText)
plainText = ""
plainText = Decrypt(encrypt edText, key, iv)
MsgBox(plainTex t)

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***@larrymck ay.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2838
by: c duden | last post by:
I am attempting to encrypt some text and be able to decrypt it at a later time. I have two methods to do this: public static Byte EncryptText(string textToEncrypt, string encryptionHash) { Byte bytearrayinput = StringAndByteManipulation.ConvertStringToByteArray(textToEncrypt); //DES instance...
11
6498
by: Beeeeeeeeeeeeves | last post by:
Hi I'm looking for some .net example code on encryption: I don't want anything fancy, no complex third party components with sophisticated algorithms, explanations of principle, or "public/private key" confusion (which seems to be all google can come up with) - I just want a SIMPLE example of how I can encrypt a string and then get back the SAME...
113
12214
by: Bonj | last post by:
I was in need of an encryption algorithm to the following requirements: 1) Must be capable of encrypting strings to a byte array, and decyrpting back again to the same string 2) Must have the same algorithm work with strings that may or may not be unicode 3) Number of bytes back must either be <= number of _TCHARs in * sizeof(_TCHAR), or the...
3
3197
by: Anon | last post by:
I made this class to encrypt my DataSet before saving it to disk. So, first in the main program I write the DataSet to XML in a MemoryStream. I pass this stream to the E_File sub, which encrypts the stream and writes it out to the FileStream. Now, in the D_File function, I read the encrypted file into a FileStream, then decrypt it into a...
11
5021
by: John Williams | last post by:
I've written a simple program to do XOR encryption as my first foray into understanding how encryption works. The code compiles fine, however it segmentation faults on every run. using gdb to debug it let me narrow the problem down to the Cipher function I think it faults at line 84 or 85. The program makes it's first read/cipher/write pass...
8
2723
by: manmit.walia | last post by:
Hello Everyone, Long time ago, I posted a small problem I had about converting a VB6 program to C#. Well with the help with everyone I got it converted. But I overlooked something and don't understand why it is doing this. Below is my code, I would be greatfull if someone can guide me through the right path or even help me solve this issue. ...
0
7603
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7806
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7568
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7891
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6151
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5159
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3553
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1139
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.