Beispiel #1
0
 public static bool CheckBase32(string base32string)
 {
     try
     {
         var tmp = Base32.FromBase32String(base32string);
         return(tmp != null);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #2
0
        public static void encryptSeed(int userId)
        {
            string seed = "CMFC4FUMEN7QNNHK4OZD2UVUIF6NJKPB";

            byte[] seedBytes = Base32.FromBase32String(seed);
            using (Aes AES = Aes.Create())
            {
                AES.KeySize   = 256;
                AES.BlockSize = 128;

                AES.Key = PrivateKey.privKey;
                AES.IV  = PrivateKey.privIV;

                AES.Mode = CipherMode.CBC;



                using (var msEncrypt = new MemoryStream())
                {
                    using (var cs = new CryptoStream(msEncrypt, AES.CreateEncryptor(), CryptoStreamMode.Write))
                    {
                        cs.Write(seedBytes, 0, seedBytes.Length);
                        cs.Close();
                    }
                    seedBytes = msEncrypt.ToArray();
                }
            }

            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "Insert Into UserSeed(seedText, userId) " +
                              "Values(@seedText, @userId);";
            cmd.Parameters.AddWithValue("@seedText", seedBytes);
            cmd.Parameters.AddWithValue("@userId", userId);
            cmd.Connection = Service.GetConnection();
            cmd.ExecuteNonQuery();
            cmd.Connection.Close();
        }
Beispiel #3
0
 private byte[] FromBase32String(string base32string)
 {
     return(Base32.FromBase32String(base32string));
 }