|
-
Sep 7th, 2010, 04:17 AM
#1
Thread Starter
Addicted Member
Simple Encryption
Hello There,
i need little help in building my own encryption im using the Xor method..i came up to create my own because i need to encrypt 10character string and i want it to output also 10character string..security is not my concerned here..what i want is encrypted string is not readable by the user or is not obvious to user..
is this possible by the use of Xor method?..BTW,its better if the output is alphanumeric.
glen
-
Sep 7th, 2010, 12:21 PM
#2
Re: Simple Encryption
As long as you remember that this is not a recommended way of encrypting anything sensitive you can use something like this:
vb.net Code:
Imports System.Text Public Class Form1 Protected Overrides Sub OnLoad(ByVal e As System.EventArgs) MyBase.OnLoad(e) '//you can use basically whatever you want for the offset Dim encrypted As String = Me.EncryptDecrypt("ThisIs10..", 3) MessageBox.Show(encrypted) Dim decrypted As String = Me.EncryptDecrypt(encrypted, 3) MessageBox.Show(decrypted) End Sub Public Function EncryptDecrypt(ByVal value As String, _ ByVal offset As Integer) As String Dim result As New StringBuilder(value.Length) For i = 0 To value.Length - 1 result.Append(Convert.ToChar( _ Convert.ToInt32(value(i)) Xor _ offset)) Next Return result.ToString() End Function End Class
I would also recommend upgrading your VS version to 2008+...
-
Sep 7th, 2010, 04:05 PM
#3
Junior Member
Re: Simple Encryption
Now there's an oxymoron.. Simple Encryption.
-
Sep 8th, 2010, 07:35 PM
#4
Thread Starter
Addicted Member
Re: Simple Encryption
 Originally Posted by ForumAccount
As long as you remember that this is not a recommended way of encrypting anything sensitive you can use something like this:
vb.net Code:
Imports System.Text Public Class Form1 Protected Overrides Sub OnLoad(ByVal e As System.EventArgs) MyBase.OnLoad(e) '//you can use basically whatever you want for the offset Dim encrypted As String = Me.EncryptDecrypt("ThisIs10..", 3) MessageBox.Show(encrypted) Dim decrypted As String = Me.EncryptDecrypt(encrypted, 3) MessageBox.Show(decrypted) End Sub Public Function EncryptDecrypt(ByVal value As String, _ ByVal offset As Integer) As String Dim result As New StringBuilder(value.Length) For i = 0 To value.Length - 1 result.Append(Convert.ToChar( _ Convert.ToInt32(value(i)) Xor _ offset)) Next Return result.ToString() End Function End Class
I would also recommend upgrading your VS version to 2008+...
Hi, there's an error in value(i).Expression is not an array or a method.
and also can i force it to display only alphanumeric character?.
i want an output like this..
string to convert:abc
first it will take the "a" and convert it to its ascii value which is 97 and the result is alphanumeric character..what would be my offset value to output alphanumeric characters..
Last edited by [gja]; Sep 8th, 2010 at 07:56 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|