Exemplo n.º 1
0
        public static string SimpleDecrypt(string enc)
        {
            byte[]   t        = Base64.Decode(Encoding.ASCII.GetBytes(enc));
            byte[]   key      = Encoding.ASCII.GetBytes("- BOBO VIERI 32-");
            Rijndael rijndael = new Rijndael();

            rijndael.InitializeKey(key);

            byte[] d = new byte[t.Length];
            rijndael.decryptCBC(t, 0, t.Length, d, 0);

            return(Encoding.ASCII.GetString(d)); //パディングがあってもNULL文字になるので除去されるはず
        }
Exemplo n.º 2
0
 public RijindaelCipher2(byte[] key, byte[] iv, CipherAlgorithm algorithm)
 {
     _rijindael = new Rijndael();
     _rijindael.SetIV(iv);
     _rijindael.InitializeKey(key);
     if (algorithm == CipherAlgorithm.AES256CTR ||
         algorithm == CipherAlgorithm.AES192CTR ||
         algorithm == CipherAlgorithm.AES128CTR)
     {
         isCTR = true;
     }
     else
     {
         isCTR = false;
     }
 }
Exemplo n.º 3
0
        public static string SimpleEncrypt(string plain)
        {
            byte[] t = Encoding.ASCII.GetBytes(plain);
            if ((t.Length % 16) != 0)
            {
                byte[] t2 = new byte[t.Length + (16 - (t.Length % 16))];
                Array.Copy(t, 0, t2, 0, t.Length);
                for (int i = t.Length + 1; i < t2.Length; i++) //残りはダミー
                {
                    t2[i] = t[i % t.Length];
                }
                t = t2;
            }

            byte[]   key      = Encoding.ASCII.GetBytes("- BOBO VIERI 32-");
            Rijndael rijndael = new Rijndael();

            rijndael.InitializeKey(key);

            byte[] e = new byte[t.Length];
            rijndael.encryptCBC(t, 0, t.Length, e, 0);

            return(Encoding.ASCII.GetString(Base64.Encode(e)));
        }
Exemplo n.º 4
0
 public RijindaelCipher2(byte[] key, byte[] iv)
 {
     _rijindael = new Rijndael();
     _rijindael.SetIV(iv);
     _rijindael.InitializeKey(key);
 }
Exemplo n.º 5
0
		public RijindaelCipher2(byte[] key, byte[] iv) {
			_rijindael = new Rijndael();
			_rijindael.SetIV(iv);
			_rijindael.InitializeKey(key);
		}
Exemplo n.º 6
0
 public RijindaelCipher2(byte[] key, byte[] iv, CipherAlgorithm algorithm) {
     _rijindael = new Rijndael();
     _rijindael.SetIV(iv);
     _rijindael.InitializeKey(key);
     if (algorithm == CipherAlgorithm.AES256CTR ||
         algorithm == CipherAlgorithm.AES192CTR ||
         algorithm == CipherAlgorithm.AES128CTR)
         isCTR = true;
     else
         isCTR = false;
 }