コード例 #1
0
ファイル: SP80038GTest.cs プロジェクト: xAmanon/bc-csharp
            public char[] Process(char[] input)
            {
                byte[] bytes = alphabetMapper.ConvertToIndexes(input);

                fpeEngine.ProcessBlock(bytes, 0, bytes.Length, bytes, 0);

                return(alphabetMapper.ConvertToChars(bytes));
            }
コード例 #2
0
ファイル: SP80038GTest.cs プロジェクト: xAmanon/bc-csharp
        private void ff3_1Test(IAlphabetMapper alphabetMapper, String skey, String stweak, String input, String output)
        {
            FpeEngine fpeEncEngine = new FpeFf3_1Engine();
            FpeEngine fpeDecEngine = new FpeFf3_1Engine();

            byte[] key   = Hex.Decode(skey);
            byte[] tweak = Hex.Decode(stweak);
            int    radix = alphabetMapper.Radix;

            fpeEncEngine.Init(true, new FpeParameters(new KeyParameter(key), radix, tweak));
            fpeDecEngine.Init(false, new FpeParameters(new KeyParameter(key), radix, tweak));

            byte[] bytes = alphabetMapper.ConvertToIndexes(input.ToCharArray());

            byte[] encryptedBytes = process(fpeEncEngine, bytes);
            IsEquals(output, new String(alphabetMapper.ConvertToChars(encryptedBytes)));

            byte[] decryptedBytes = process(fpeDecEngine, encryptedBytes);
            IsTrue(Arrays.AreEqual(bytes, decryptedBytes));
            char[] chars = alphabetMapper.ConvertToChars(decryptedBytes);
            IsEquals(input, new String(chars));
        }