Archived Forum Post

Index of archived forum posts

Question:

What is wrong with my TwoFish Encryption

Jun 22 '15 at 10:58

Hi when i run the following code i don't get an error but i don't get an output either?

private void TwoFish_Encrypt()
    {
        Chilkat.Crypt2 crypt = new Chilkat.Crypt2();
        crypt.CryptAlgorithm = "twofish";
        crypt.CipherMode = "ecb";
        crypt.KeyLength = 256;
        crypt.PaddingScheme = 0;
        crypt.EncodingMode = "base64";
        var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(Genkey.Text);
        string keybase64 = System.Convert.ToBase64String(plainTextBytes);
        crypt.SetEncodedKey(keybase64, "base64");
        string encStr = crypt.EncryptStringENC(Input.Text);
        DecryptText.Text = encStr;
    }

Answer

Chilkat doesn't raise exceptions, so it's important to check the LastErrorText property after a method call fails. Can you post the contents of the LastErrorText property after calling SetEncodedKey and again after calling EncryptStringEnc (please put the results in <pre></pre> tags.