How can I decrypt a string in classic-ASP/VBScript? The string comes from a php application that uses 3DES encryption.
相关问题
- If condition not working in classic ASP
- How to programmatically convert Access 1997 .mdb t
- IE8 Form Not Submitting (Intermittent)
- Server.Transfer from ASP to ASP.Net
- VBScript / ADODB Syntax Issue with adArray?
相关文章
- Can a VBScript function return a dictionary?
- UTC Time Assignment in VBScript
- Copy and Rename File VBScript
- How do I open a file with VBScript?
- ZURB Foundation, switching tab programmatically
- Import WinAPI Function in *.VBS File
- How to reference the mail which triggered the outl
- Accessing COM Component from Classic ASP which con
There's a TripleDES JavaScript implementation here: http://www.tero.co.uk/des/. It works as JScript (Microsoft's Classic ASP version of JavaScript, basically ECMAScript 3), is checked against PHP, supports EBC and CBC, padding (zeroes, PKCS7(buggy) or spaces) and also does plain DES. You can use it in a Classic ASP VBScript page like this:
Resulting in:
If you use PKCS7 padding, note that there's a bug in the JavaScript: padding code. The initial
if (padding ==
block should be enclosed in anif (encrypt) {...}
test, and the last two lines of des() should be replaced with:I have a Javascript implementation of DES/TripleDES. It does CBC and ECB modes, and for padding supports PKCS7, Spaces, or Zeroes. It's integrated with a RFC2898-compliant PBKDF2, so it can generate encryption keys and IV's from passwords if you like. You can also set the crypto key and IV explicitly.
It is usable when calling directly from Javascript - any browser, or from Rhino, or WScript.exe, or maybe closer to your case, classic ASP using Javascript.
I've also packaged it as a COM component, so it is possible to call it from any COM-compliant environment, like VBScript running in classic ASP, or Perl, or VBA, etc.
It is an independent implementation, and is fully compliant with and interoperable with the .NET DESCryptoServiceProvider and TripleDESCryptoServiceProvider.
Get it here: http://cheeso.members.winisp.net/srcview.aspx?dir=DES
When calling it directly from Javascript, it looks like this:
When calling the COM component from VBScript, it looks like this:
The encryption is pretty fast but the key generation is not.
Edit:
you can also use the Javascript DES stuff in a browser.
here's an example: http://jsbin.com/oguye3
I would try using CAPICOM from Microsoft. There are examples included with the SDK that will get you rolling.
Old overview:
http://msdn.microsoft.com/en-us/library/ms995332.aspx
CAPICOM SDK:
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=860ee43a-a843-462f-abb5-ff88ea5896f6
The example you'll want to check out is located here on my machine:
C:\Program Files (x86)\Microsoft CAPICOM 2.1.0.2 SDK\Samples\html\EncryptedData.htm