473,769 Members | 5,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Security - 3DES and RC2

I have been trying to create encoding/decoding functions for secure Credit
Card information.

I was looking at 3DES/MD5 and RC2/MD5.

I found a simple function that seemed to work pretty well, but I am confused
as to what is happening.

In the routine I found it was using the TripleDESCrypto ServiceProvider (and
not the RC2CryptoServic eProvider) class. But in the CryptDeriveKey, it was
passed RC2 and MD5 and 128 bit size (3DES uses 168). It does seem to work,
however.

Why is that?

*************** *************** ******

Public Shared Function TripleDESEncode (ByVal value As String, ByVal key
As String) As String

Dim des As New Security.Crypto graphy.TripleDE SCryptoServiceP rovider

des.IV = New Byte(7) {}

Dim pdb As New Security.Crypto graphy.Password DeriveBytes(key , New
Byte(-1) {})

des.Key = pdb.CryptDerive Key("RC2", "MD5", 128, New Byte(7) {})

Dim ms As New IO.MemoryStream ((value.Length * 2) - 1)

Dim encStream As New Security.Crypto graphy.CryptoSt ream(ms,
des.CreateEncry ptor(), Security.Crypto graphy.CryptoSt reamMode.Write)

Dim plainBytes As Byte() = Text.Encoding.U TF8.GetBytes(va lue)

encStream.Write (plainBytes, 0, plainBytes.Leng th)

encStream.Flush FinalBlock()

Dim encryptedBytes( CInt(ms.Length - 1)) As Byte

ms.Position = 0

ms.Read(encrypt edBytes, 0, CInt(ms.Length) )

encStream.Close ()

Return Convert.ToBase6 4String(encrypt edBytes)

End Function
*************** *************** *****

Should I use the:

RC2CryptoServic eProvider
and
CryptDeriveKey( "RC2", "MD5", 128, New Byte(7) {})

and/or

TripleDESCrypto ServiceProvider
and
CryptDeriveKey( "TripleDES" , "MD5", 168, New Byte(7) {})

I was thinking of setting up a Class that had both.

Also, I also saw the size as 0:

CryptDeriveKey( "TripleDES" , "MD5", 0, New Byte(7) {})

Does that mean it is using the largest possible size?

Thanks,

Tom
Jun 13 '06 #1
0 1148

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
766
by: underwmd | last post by:
Hello, My problem is two fold. 1) I must support a deployed legacy application written in VB6 SP5. I need to export data from a database, compress it and the encrypt the data using 3DES (to prevent tampering) data gets transmitted at night to the home office of my company. Rewriting this application in .NET is not an option as the application was 5 years in development.
11
4894
by: underwmd | last post by:
Hello, My problem is two fold. 1) I must support a deployed legacy application written in VB6 SP5. I need to export data from a database, compress it and the encrypt the data using 3DES (to prevent tampering) data gets transmitted at night to the home office of my company. Rewriting this application in .NET is not an option as the application was 5 years in development.
2
3050
by: | last post by:
Greetings, I am trying to build an interface into an existing system which accepts UTF-8 encoded "messages". In these messages, there is a unencrypted base64 "key" in the header which is used to encrypt the "body" of the remainder of the document. How do I do simple encryption and decryption within VB.NET ? Could someone point me any good examples for performing the following tasks:
1
8040
by: Sathyaish | last post by:
I have the following scenario: Algorithm: 3DES Cipher Mode: CBC Key Size: 128-bit Block Size: 64 bit IV: 0x0000000000000000 (an eight byte array of zeros) The results I get using .NET with the following routine are:
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9990
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9861
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.