How to make VBA and Java's tripledes algorithm common

Source: Internet
Author: User

This article link: http://www.cnblogs.com/Charltsing/p/TripleDES.html

As we all know, the tripledes algorithm that Java uses by default is the Ecb+pkcs#5 fill method. The VB6 algorithm that can be found online is incompatible with this.

Is there a simple way to achieve the common use between the two?

As you know, C # is capable of implementing the TripleDES algorithm, so you can invoke the static class of. NET in VBA, VBS, and vb6.0 to implement an encryption and decryption algorithm that is common to Java.

In VBA, call C # 's TripleDESCryptoServiceProvider, and set mode = CIPHERMODE.ECB.

If you have other questions, you can contact QQ564955427

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

It is important to note that C # supports the Pkcs#7 fill mode by default, and the pkcs#5 fill is generic by default, depending on the following text:

you can find the difference between the two definitions by reading the resources below:
[Def] PKCS #7: Cryptographic Message Syntax Standard,
An RSA laboratories Technical Note, Version 1.5. Revised November 1, 1993. HTTP://WWW.CNBLOGS.COM/MIDEA0978/ADMIN/FTP://FTP.RSA.COM/PUB/PKCS/ASCII/PKCS-7.ASC
[INF] PKCS #5: password-based Encryption Standard,
An RSA laboratories Technical Note, Version 1.5. Revised November 1, 1993. HTTP://WWW.CNBLOGS.COM/MIDEA0978/ADMIN/FTP://FTP.RSA.COM/PUB/PKCS/ASCII/PKCS-5.ASC
In pkcs5padding, it is clear that the size of the block is 8 bits, whereas in the pkcs7padding definition, the size of the block is indeterminate and can be between 1-255 (the length of the block is beyond 255), and the algorithm for populating the values is the same:
value=k-(l mod k), k= block size, l= data length, if l=8, you need to populate additional 8 byte 8
In . NET, for example, TripleDESCryptoServiceProvider, the default blocksize=64bits=8bytes, so in this case, in pkcs5padding=pkcs7padding.
If you define an encryption block size that is not 64bits in C # and use pkcs7padding at the same time, then the pkcs5padding that uses the JDK standard in Java cannot be decrypted.

How to make VBA and Java's tripledes algorithm common

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.