Esempio n. 1
0
    //tutaj jest enkrypcja i dekrypcja
    public void EncryptTest()
    {
        TwoFish tf = new TwoFish();

        tf.GenerateKeys(TwoFish.ConvertHexToBitArray("00000000000000000000000000000000"));
        BitArray encrypted = tf.Encrypt(TwoFish.ConvertHexToBitArray("00000000000000000000000000000000"));

        tf.DebugBits(encrypted);
        BitArray decrypted = tf.Decrypt(encrypted);

        tf.DebugBits(decrypted);
    }
Esempio n. 2
0
    public void SingleLoopTest()
    {
        TwoFish tf = new TwoFish();

        tf.GenerateKeys(TwoFish.ConvertHexToBitArray("00000000000000000000000000000000"));
        BitArray[] wt = tf.InputWhitening(TwoFish.ConvertHexToBitArray("00000000000000000000000000000000"));
        BitArray[] wn = tf.SingleRound(wt[0], wt[1], wt[2], wt[3], 0);

        tf.DebugBits(wn[0]);
        tf.DebugBits(wn[1]);
        tf.DebugBits(wn[2]);
        tf.DebugBits(wn[3]);
    }
Esempio n. 3
0
    private string text128bit = "000102030405060708090A0B0C0D0E0F"; //"54776F46697368206973206E69636520";

    public string StartTwofish(string asset, bool shouldEncrypt)
    {
        TwoFish  tf    = new TwoFish();
        BitArray bytes = TwoFish.ConvertHexToBitArray(key);

        tf.GenerateKeys(bytes);
        string result = "";

        if (shouldEncrypt)
        {
            result = tf.Encrypt(asset);
        }
        else
        {
            result = tf.Decrypt(asset);
        }
        return(result);
    }