Exemple #1
0
        /// <summary>
        /// Converts a .NET string into a CryptoString. It is recommended for the application to assign the 'string' argument
        /// with Random Text using the GenerateRandomText() method to overwrite the original string.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static CryptoString StringToCryptoString(string value)
        {
            CryptoString cryptoString = new CryptoString(StringToSecureString(value));

            value = GenerateRandomText(10000);
            return(cryptoString);
        }
Exemple #2
0
        public string GetStringHash(HashAlgorithm algorithm = null)
        {
            HashAlgorithm a = algorithm == null?SHA256.Create() : algorithm;

            Hasher hasher = new Hasher(a);
            string hash   = hasher.Hash(CryptoString.SecureStringToString(GetSecureString()));

            return(hash);
        }
Exemple #3
0
        /// <summary>
        /// Converts a .NET SecureString into a CryptoString.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static SecureString StringToSecureString(string value)
        {
            SecureString secure = new SecureString();

            foreach (char c in value)
            {
                secure.AppendChar(c);
            }
            value = CryptoString.GenerateRandomText(10000);
            return(secure);
        }
Exemple #4
0
 public CryptoString(string passphrase) : this(CryptoString.StringToSecureString(passphrase))
 {
 }