Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Encyption

Status
Not open for further replies.

SQLScholar

Programmer
Aug 21, 2002
2,127
GB
Hey all,

What I am looking to do is this.

1) End user wants to do something which requires authorisation. So they click a box which brings up a screen showing

- Label with random string
- Combo with list of person who authorised
- textbox to type in

They phone up the poeple who can authorise it - they then read over the phone the string (if agreed).

2) The person who authorises it, types it into an app. Using the name of the person who Authorises it we encrypt the string and read it back.

3) The person then selects the name of the person who agreed and the authorisation code.

If sucessfull we then do some stuff....

But basically what i am looking for is an encryption algorithm which if the same key is used on the same string - you get the same result.

If possible would rather it wasnt a DLL or API - but not too worried if it is. I have looked online at various options but i am never sure if the same key\result thing will work.

If anyone can point me in the correct direction - i would be greatful.

TIA

Dan

----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
The DotNet framework itself supports this sort of functionality, but I haven't personally used it...

Suggest you google "symmetric encryption dotnet" - should turn up something...

mmilan

 
Bugger.

Just realised I'm in the vb6 forum... Sorry about that.

Erm - create an interop assembly?

Martin
 
There is thread222-535644 where Strongm shows you how to use MD5 encryption.

This is somewhat complex code and may be overkill for what you are doing but it will certainly handle it.

 
Golom,

Thanks for this - i saw this one earlier though and gave it a go.

Seems that when encrypted it becomes as string of unuseable characters - not something that could be read over the phone. Heres whats displayed on my screen with this code

Code in: 1234-1234-1234-1234
Encrpted: ????????z?????????G
Code out: 1234-1234-1234-1234

Any other ideas - or if i am doing anything wrong?

Dan

----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
Rather than a nice text string (which would probably be garbage) you might try using the Byte array that the system uses. On my system

1234-1234-1234-1234

using the Encryption Key "Clydesdale"

produces the byte array

[tt]
15 119 29 255 132 253 91 160 115 226 207 77 25 153 177 175 27 19 250 20 0 217 215 180 41 238 20 209 195 153 20 24 137 157 85 4 192 0
[/tt]

That can be Decrypted to your original string.
Might be a bit long to read over the phone however.
 
I've illustrated how to use CAPI (Microsoft's built-in cryptographic API)several times in this forum, both as an API and as an object (CAPICOM). A keyword search ought to find something
 
>as string of unuseable characters

That thread was followed up by another one which showed how to turn those 'unuseable' characters into a useable string.

Basically, take the unuseable string s and pass it through:

h = ""
For i = 1 To Len(s)
h = h & Right("0" & Hex(Asc(Mid(s, i, 1))), 2)
Next
 
Strongm,

Thanks for your help - as i said i used your code on the previous thread. So i have run the string through your above code.

So i start with

1234-4566-5876-2545

Its translated into

3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F46

Which still isnt that useful (in terms of reading over the phone)?

Just to check i have this correct - i have put

s = Text2.Text
h = ""
For i = 1 To Len(s)
h = h & Right("0" & Hex(Asc(Mid(s, i, 1))), 2)
Next
Text2.Text = h

and text2 currently has the encrypted data.

So - is there a better way to do this? Maybe not encryption but algorithm which isnt easily spotted by an end user. Any ideas?

Dan

----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
>text2 currently has the encrypted data.

No, actually it doesn't. It has what it has what the textbox has translated the underlying buffer into (as the remarks in the code points out)

You need the original encrypted buffer, not the contents of text2 (i.e. 'result' in Command1_Click code shown in that example). Note that the example decrypt that I provide in Command1_Click decodes 'result' and not Text2

Having said that, it sounds like you want a message digest - and here's an example of RSA's MD5
Code:
[blue]Option Explicit

' =====================================================================================
' All declares necessary for MS implementation of RSA MD5<function> in cryptdll library
' Requires XP/2000/2003
Private Type MD5_CTX
  i(1 To 2) As Long
  buf(1 To 4) As Long
  inp(1 To 64) As Byte
  digest(1 To 16) As Byte
End Type

Private Declare Sub MD5Init Lib "cryptdll" (Context As MD5_CTX)
Private Declare Sub MD5Update Lib "cryptdll" (Context As MD5_CTX, ByVal strInput As String, ByVal lLen As Long)
Private Declare Sub MD5Final Lib "cryptdll" (Context As MD5_CTX)

' RSA MD5 Variant
Private Function HashVersion1(ByVal strPassword As String) As String
    Dim myContext As MD5_CTX
    
    MD5Init myContext
    MD5Update myContext, strPassword, Len(strPassword)
    MD5Final myContext
    
    HashVersion1 = StrConv(myContext.digest, vbUnicode)
End Function[/blue]
but even with that you'll get odd characters (that will display differently depending on what font you have selected). So what you may want sounds like a 7-bit MIME encoding of the buffer, something like Base64


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top