Esempio n. 1
0
        public static byte[] csHashBytes(string Message)
        {
            byte[] MessageBytes = TCipher.RegularStringToBytes(Message);
            SHA1   sha          = new SHA1CryptoServiceProvider();

            return(sha.ComputeHash(MessageBytes));
        }
Esempio n. 2
0
        public static string csGetLayout(this GridView gv)
        {
            MemoryStream ms = new MemoryStream();

            gv.SaveLayoutToStream(ms);
            var b = ms.ToArray();

            return(TCipher.BytesToBase64String(b));
        }
Esempio n. 3
0
 public static string EncryptStringToBase64(string Value, string key)
 {
     if (string.IsNullOrEmpty(Value) || string.IsNullOrEmpty(key))
     {
         return(string.Empty);
     }
     byte[] keyb   = Parameter(key);
     byte[] cypher = TCipher.encryptStringToBytes_AES(Value, keyb);
     return(BytesToBase64String(cypher));
 }
Esempio n. 4
0
        public static void csSetLayout(this GridView gv, string s64)
        {
            if (string.IsNullOrEmpty(s64))
            {
                return;
            }
            byte[]       b  = TCipher.Base64toBytes(s64);
            MemoryStream ms = new MemoryStream(b);

            gv.RestoreLayoutFromStream(ms);
        }
Esempio n. 5
0
        public static string DotKey(string UserID, string UserName, string Password)
        {
            string s = UserID + Password + UserName + Password;

            while (s.Contains(" "))
            {
                int i = s.IndexOf(' ');
                s = s.Remove(i, 1);
            }
            s = s.ToUpper();
            return(IntToDotted(TCipher.csHashint32(s)));
        }
Esempio n. 6
0
        private static int ProcessInput(string s)
        {
            while (s.Contains(" "))
            {
                int i = s.IndexOf(' ');
                s = s.Remove(i, 1);
            }
            s = s.ToUpper();
            int v = TCipher.csHashint32(s);

            return(v);
        }
Esempio n. 7
0
        public static string GetWindowsValidationCode(string uid, string key)
        {
            string        domain = Environment.UserDomainName;
            StringBuilder sb     = new StringBuilder(key);

            sb.Append(uid);
            sb.Append(key);
            sb.Append(domain);
            sb.Append(key);
            sb.Append(domain);
            sb.Append(uid);
            sb.Append(key);
            string s = TCipher.SliceAndDice(sb.ToString());

            return(TCipher.PrintableString(s));
        }
Esempio n. 8
0
        public static string DecryptString(string Value64, string Password)
        {
            if (string.IsNullOrEmpty(Value64) || string.IsNullOrEmpty(Password))
            {
                return(string.Empty);
            }
            try
            {
                byte[] key    = Parameter(Password);
                byte[] cypher = TCipher.Base64toBytes(Value64);
                return(decryptStringFromBytes_AES(cypher, key));
            }
            catch
            {
#if (DEBUG)
                {
                    throw new Exception("Invalid Operation");
                }
#else
                { return(string.Empty); }
#endif
            }
        }
Esempio n. 9
0
        public static int csHashint32(this string MessageString) // Secure hash
        {
            if (MessageString == null)
            {
                return(0);
            }
            //convert the string into an array of Unicode bytes.
            byte[] MessageBytes = TCipher.RegularStringToBytes(MessageString);

            //Create a new instance of the SHA1Managed class to create
            //the hash value.
            SHA1Managed SHhash = new SHA1Managed();

            //Create the hash value from the array of bytes.
            byte[] HashValue = SHhash.ComputeHash(MessageBytes);
            int    v         = 0;

            for (int i = 6; i < 10; i++)
            {
                byte b = HashValue[i];
                v = (v << 8) + HashValue[i];
            }
            return(v);
        }
Esempio n. 10
0
 public static int GetPassword(string p, string key)
 {
     return(TCipher.csHashint32(TCipher.SliceAndDice(p + key)));
 }
Esempio n. 11
0
 //public static string RSAEncrypt(string PlainText, string Key)
 //{
 //    byte[] plainBytes = TCipher.RegularStringToBytes(PlainText);
 //    return TCipher.BytesToRegularString(RSAEncrypt(plainBytes, Key));
 //}
 public static string RSAEncryptToBase64(string PlainText, string Key)
 {
     byte[] plainBytes = TCipher.RegularStringToBytes(PlainText);
     return(TCipher.BytesToBase64String(RSAEncrypt(plainBytes, Key)));
 }
Esempio n. 12
0
 public static string RSADecrypt(string Base64CipherText, string Key)
 {
     byte[] bEncryptedText = TCipher.Base64toBytes(Base64CipherText);
     byte[] bPlainText     = TCipher.RSADecrypt(bEncryptedText, Key);
     return(BytesToRegularString(bPlainText));
 }
Esempio n. 13
0
 public static string PrintableString(string Message)
 {
     return(TCipher.StringToBase64(Message));
 }
Esempio n. 14
0
 public bool Validate(string password)
 {
     return(KEY == TCipher.GenerateTumbler(USERID, NAME, password));
 }
Esempio n. 15
0
 public TReEventTypetration(string Userid_HEX, string Key_DD, string Name)
 {
     USERID = MyLib.HexToInt(Userid_HEX);
     KEY    = TCipher.DottedToInt(Key_DD);
     NAME   = Name;
 }