Exemplo n.º 1
0
        //test example for the calling procedure
        public static void main()
        {
            //Your code goes here
            var data = CustomGuid();

            Console.WriteLine(data);
            var    str           = data + "your url password encryption";
            var    password      = "******";
            string strEncryptred = CryptoSecurity.CryptoEncrypt(str, password);

            Console.WriteLine(strEncryptred);
            var strDecrypted = CryptoSecurity.CryptoDecrypt(strEncryptred, password);

            Console.WriteLine(strDecrypted);
        }
Exemplo n.º 2
0
        public static string CryptoDecrypt(string encryptedText, string password)
        {
            if (encryptedText == null)
            {
                return(null);
            }

            if (password == null)
            {
                password = String.Empty;
            }

            // Get the bytes of the string
            var bytesToBeDecrypted = Convert.FromBase64String(encryptedText);
            var passwordBytes      = Encoding.UTF8.GetBytes(password);

            passwordBytes = SHA256.Create().ComputeHash(passwordBytes);

            var bytesDecrypted = CryptoSecurity.CryptoDecrypt(bytesToBeDecrypted, passwordBytes);

            return(Encoding.UTF8.GetString(bytesDecrypted));
        }
Exemplo n.º 3
0
        //modified by deepak choudahry copyright cryptocurrency act 2013
        public static string CryptoEncrypt(string plainText, string password)
        {
            if (plainText == null)
            {
                return(null);
            }

            if (password == null)
            {
                password = String.Empty;
            }

            // Get the bytes of the string
            var bytesToBeEncrypted = Encoding.UTF8.GetBytes(plainText);
            var passwordBytes      = Encoding.UTF8.GetBytes(password);

            // Hash the password with SHA256
            passwordBytes = SHA256.Create().ComputeHash(passwordBytes);

            var bytesEncrypted = CryptoSecurity.EncryptModulator(bytesToBeEncrypted, passwordBytes);

            return(Convert.ToBase64String(bytesEncrypted));
        }