login about faq

Hi to All! How we can traslate this code 'to speak' with asp ?

thanks, bajo.

String doDecode(String password, String text) throws Exception { SecretKey key = getKey(password);

        //IMPORTANT TO GET SAME RESULTS ON iOS and ANDROID
        final byte[] iv = new byte[16];
        Arrays.fill(iv, (byte) 0x00);
        IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);

        byte[] encrypedPwdBytes = Base64.decode(text, Base64.DEFAULT);
        // cipher is not thread safe
        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
        cipher.init(Cipher.DECRYPT_MODE, key, ivParameterSpec);
        byte[] decrypedValueBytes = (cipher.doFinal(encrypedPwdBytes));

        String decrypedValue = new String(decrypedValueBytes);
        LogHelpers.DebugLog("Decrypted: " + text + " -> " + decrypedValue);
        return decrypedValue;

asked May 29 '14 at 05:07

bajo's gravatar image

bajo
1613


It would be something like this:

set crypt = Server.CreateObject("Chilkat_9_5_0.Crypt2")

success = crypt.UnlockComponent("Anything for 30-day trial")

crypt.CryptAlgorithm = "aes" crypt.CipherMode = "cbc" ' Set the key length to 128 or 256, depending on your key size. crypt.KeyLength = 256

' 0 = PKCS7Padding crypt.PaddingScheme = 0

crypt.EncodingMode = "base64"

ivHex = "00000000000000000000000000000000" crypt.SetEncodedIV ivHex,"hex"

' We have 32 bytes here for a 256-bit key keyHex = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F" crypt.SetEncodedKey keyHex,"hex"

decryptedStr = crypt.DecryptStringENC(encryptedBase64Str)

The challenge is to make sure you set the exact same binary key. Your code snippet above transforms a password string to the exact binary secret key via the getKey(password) call. You would need to know the exact algorithm/transformation that is used to transform from a password string to a 16-bit or 32-byte key, and this would need to be duplicated in the ASP code..

link

answered Jun 06 '14 at 07:59

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×23
×22
×8

Asked: May 29 '14 at 05:07

Seen: 1,130 times

Last updated: Jun 06 '14 at 07:59

powered by OSQA