• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Cryptography.SHA1CryptoServiceProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Security.Cryptography.SHA1CryptoServiceProvider的典型用法代码示例。如果您正苦于以下问题:C# System.Security.Cryptography.SHA1CryptoServiceProvider类的具体用法?C# System.Security.Cryptography.SHA1CryptoServiceProvider怎么用?C# System.Security.Cryptography.SHA1CryptoServiceProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



System.Security.Cryptography.SHA1CryptoServiceProvider类属于命名空间,在下文中一共展示了System.Security.Cryptography.SHA1CryptoServiceProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetSha1Hash

 public static string GetSha1Hash(this string value)
 {
     var encoding = new UTF8Encoding();
     var hash = new System.Security.Cryptography.SHA1CryptoServiceProvider();
     var hashed = hash.ComputeHash(encoding.GetBytes(value));
     return encoding.GetString(hashed);
 }
开发者ID:MrHayato,项目名称:PhotoCache,代码行数:7,代码来源:StringExtensions.cs


示例2: GetSHA1Hash

        public static string GetSHA1Hash(string pathName)
        {
            string strResult = "";
            string strHashData = "";

            byte[] arrbytHashValue;
            System.IO.FileStream oFileStream = null;

            System.Security.Cryptography.SHA1CryptoServiceProvider oSHA1Hasher =
                       new System.Security.Cryptography.SHA1CryptoServiceProvider();

            try
            {
                oFileStream = GetFileStream(pathName);
                arrbytHashValue = oSHA1Hasher.ComputeHash(oFileStream);
                oFileStream.Close();

                strHashData = System.BitConverter.ToString(arrbytHashValue);
                strHashData = strHashData.Replace("-", "");
                strResult = strHashData;
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error!",
                         System.Windows.Forms.MessageBoxButtons.OK,
                         System.Windows.Forms.MessageBoxIcon.Error,
                         System.Windows.Forms.MessageBoxDefaultButton.Button1);
            }

            return (strResult);
        }
开发者ID:VISTALL,项目名称:game-updater,代码行数:31,代码来源:DTHasher.cs


示例3: init

 public void init()
 {
     //    signature=java.security.Signature.getInstance("SHA1withRSA");
     //    keyFactory=KeyFactory.getInstance("RSA");
     sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
     cs = new System.Security.Cryptography.CryptoStream(System.IO.Stream.Null, sha1, System.Security.Cryptography.CryptoStreamMode.Write);
 }
开发者ID:salimci,项目名称:Legacy-Remote-Recorder,代码行数:7,代码来源:SignatureRSA.cs


示例4: GetSHA1Hash

        public static string GetSHA1Hash(string pathName)
        {
            string strResult = "";
            string strHashData = "";

            byte[] arrbytHashValue;
            System.IO.FileStream oFileStream = null;

            System.Security.Cryptography.SHA1CryptoServiceProvider oSHA1Hasher =
                       new System.Security.Cryptography.SHA1CryptoServiceProvider();

            try
            {
                oFileStream = GetFileStream(pathName);
                arrbytHashValue = oSHA1Hasher.ComputeHash(oFileStream);
                oFileStream.Close();

                strHashData = System.BitConverter.ToString(arrbytHashValue);
                strHashData = strHashData.Replace("-", "");
                strResult = strHashData;
            }
            catch (System.Exception)
            {
            }

            return (strResult);
        }
开发者ID:atom0s,项目名称:Campah,代码行数:27,代码来源:Updater.xaml.cs


示例5: Generate

        public static string Generate()
        {
            // Generate random
            var rnd = new System.Security.Cryptography.RNGCryptoServiceProvider();
            var entropy = new byte[bytes - 4];
            try {
                rnd.GetBytes(entropy);
            } finally {
                rnd.Dispose();
            }

            // Hash
            var sha = new System.Security.Cryptography.SHA1CryptoServiceProvider();
            byte[] hash;
            try {
                hash = sha.ComputeHash(entropy);
            } finally {
                sha.Dispose();
            }

            // Compute output
            var raw = new byte[bytes];
            Array.Copy(entropy, 0, raw, 0, bytes - 4);
            Array.Copy(hash, 0, raw, bytes - 4, 4);

            // Convert to Base64
            return Convert.ToBase64String(raw).Replace('+', '!').Replace('/', '~');
        }
开发者ID:invertedtomato,项目名称:Amos2,代码行数:28,代码来源:Tokens.cs


示例6: GetFeatureOfHuman

        public static Guid GetFeatureOfHuman(byte[] humanDescriptionBytes)
        {
            byte[] hashedBytes = new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash(humanDescriptionBytes);

            Array.Resize(ref hashedBytes, 16);

            return new Guid(hashedBytes);
        }
开发者ID:ViniciusConsultor,项目名称:ecustomsgs1,代码行数:8,代码来源:XRayController.cs


示例7: GetCryptographyString

        private static string GetCryptographyString(string strSource)
        {
            System.Security.Cryptography.SHA1CryptoServiceProvider sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
            byte[] bytes = sha1.ComputeHash(System.Text.Encoding.Default.GetBytes(strSource));
            string result = BitConverter.ToString(bytes, 4, 8).Replace("-","");

            return result;
        }
开发者ID:wangsying,项目名称:EasySite,代码行数:8,代码来源:CurrentUser.cs


示例8: createHash

        /// <summary>
        /// Retorna el hash SHA1 de la cadena de texto que recibe como parámetro.
        /// </summary>
        /// <param name="unHashed">Cadena de texto a encriptar.</param>
        /// <returns>Hash de la cadena de texto. SHA1.</returns>
        public static string createHash(string unHashed)
        {
            System.Security.Cryptography.SHA1CryptoServiceProvider x = new System.Security.Cryptography.SHA1CryptoServiceProvider();
            byte[] data = System.Text.Encoding.ASCII.GetBytes(unHashed);
            data = x.ComputeHash(data);

            return Convert.ToBase64String(data);
        }
开发者ID:jlsarmientoh,项目名称:EstacionDB,代码行数:13,代码来源:Security.cs


示例9: GenerateAuthorizationToken

 private static string GenerateAuthorizationToken(string passTypeIdentifier, string serialNumber)
 {
     using (System.Security.Cryptography.SHA1CryptoServiceProvider hasher = new System.Security.Cryptography.SHA1CryptoServiceProvider())
     {
         byte[] data = Encoding.UTF8.GetBytes(passTypeIdentifier.ToLower() + serialNumber.ToLower() + mAuthorizationKey);
         return System.BitConverter.ToString(hasher.ComputeHash(data)).Replace("-", string.Empty).ToLower();
     }
 }
开发者ID:joe-keane,项目名称:dotnet-passbook,代码行数:8,代码来源:PassbookBaseController.cs


示例10: Hash

 private static string Hash(string toHash)
 {
     System.Security.Cryptography.SHA1CryptoServiceProvider x = new System.Security.Cryptography.SHA1CryptoServiceProvider();
     byte[] data = System.Text.Encoding.ASCII.GetBytes(toHash);
     data = x.ComputeHash(data);
     string o = BitConverter.ToString(data).Replace("-", "").ToUpper();
     return o;
 }
开发者ID:tylermenezes,项目名称:Rfid-Credential-Provider,代码行数:8,代码来源:Program.cs


示例11: Main

        public static string root = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // string root points to MyDocuments

        #endregion Fields

        #region Methods

        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                if (args[0] == "-v")
                {
                    Console.WriteLine("asdasd");
                    if (File.Exists(prefs + "/gkey"))
                    {
                            using (System.IO.StreamReader sr = new System.IO.StreamReader(prefs + "/gkey"))
                            {
                                string data = sr.ReadToEnd();
                                string[] f = data.Split('\n');
                                sr.Dispose();
                                if (f[0] == "accepted")
                                {
                                    string HASH = f[1].ToString();
                                    using (System.Security.Cryptography.SHA1CryptoServiceProvider sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider())
                                    {
                                        string hashsum = string.Empty;                  // Empty storage allocator
                                        byte[] da = sha1.ComputeHash(Encoding.Unicode.GetBytes(prefs + "/gkey"));       // byte array
                                        foreach (byte by in data)
                                        {
                                            hashsum += String.Format("{0,2:X2}", by);        // :-)
                                        }

                                        if (hashsum.ToString() != HASH.ToString())
                                        {
                                            Console.ForegroundColor = ConsoleColor.Red;
                                            Console.Write("SECURITY COMPROMISED!\n\nSHA1 HASH MODIFIED!\nRECORD DOES NOT MATCH G_KEY!\n\nCACHE WILL BE DELETED FOR SECURITY.");
                                            Console.Read();

                                        }

                                        else ;
                                        sha1.Dispose();

                                        try
                                        {
                                            Directory.Delete(prefs);
                                        }

                                        catch { ; }
                                    }
                                }

                            }

                    }
                }

            }

            else
            {
                Console.Write("This is not a standalone application.");
            }
        }
开发者ID:kryptonX,项目名称:Scale,代码行数:64,代码来源:Program.cs


示例12: EncryptToSHA1

 public string EncryptToSHA1(string str)
 {
     System.Security.Cryptography.SHA1CryptoServiceProvider sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
     byte[] str1 = System.Text.Encoding.UTF8.GetBytes(str);
     byte[] str2 = sha1.ComputeHash(str1);
     sha1.Clear();
     (sha1 as IDisposable).Dispose();
     return Convert.ToBase64String(str2);
 }
开发者ID:iCnG,项目名称:myGitHub,代码行数:9,代码来源:Default.aspx.cs


示例13: GetSHA1

 public static string GetSHA1(string pwdata_s)
 {
     System.Security.Cryptography.SHA1CryptoServiceProvider osha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
     ASCIIEncoding enc = new ASCIIEncoding();
     byte[] pwdata_b = enc.GetBytes(pwdata_s);//password(string) to byte[]
     byte[] pwsha1_b = osha1.ComputeHash(pwdata_b);//ToHash
     string pwsha1_s = BitConverter.ToString(pwsha1_b).Replace("-", "");//hash to string
     return pwsha1_s;
 }
开发者ID:RhodesZ,项目名称:Seekme,代码行数:9,代码来源:Login.cs


示例14: sha1

 public string sha1(string input)
 {
     byte[] hash;
     using (var sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider())
         hash = sha1.ComputeHash(Encoding.Unicode.GetBytes(input));
     var sb = new StringBuilder();
     foreach (byte b in hash) sb.AppendFormat("{0:x2}", b);
     return sb.ToString();
 }
开发者ID:alexeykuzmin7,项目名称:Diplom_project,代码行数:9,代码来源:Form7.cs


示例15: HashString

 public static string HashString(string Value)
 {
     System.Security.Cryptography.SHA1CryptoServiceProvider x = new System.Security.Cryptography.SHA1CryptoServiceProvider();
     byte[] data = System.Text.Encoding.ASCII.GetBytes(Value);
     data = x.ComputeHash(data);
     string ret = "";
     for (int i = 0; i < data.Length; i++)
         ret += data[i].ToString("x2").ToLower();
     return ret;
 }
开发者ID:pederjohnsen,项目名称:Nimbus,代码行数:10,代码来源:Security.cs


示例16: ComputeSHA1Hash

 public string ComputeSHA1Hash(string input)
 {
     var encrypter = new System.Security.Cryptography.SHA1CryptoServiceProvider();
     using (var sw = new StringWriter())
     {
         foreach (byte b in encrypter.ComputeHash(Encoding.UTF8.GetBytes(input)))
             sw.Write(b.ToString("x2"));
         return sw.ToString();
     }
 }
开发者ID:EzyWebwerkstaden,项目名称:n2cms,代码行数:10,代码来源:Form1.cs


示例17: encrypt

        /// <summary>
        /// Método para encriptar un string. En este caso se usa para el Pass.
        /// </summary>
        /// <param name="password">Contraseña a encriptar</param>
        /// <returns>Cadena encriptada</returns>
        private static string encrypt(string password)
        {
            System.Security.Cryptography.HashAlgorithm hashValue = new System.Security.Cryptography.SHA1CryptoServiceProvider();
            byte[] bytes = System.Text.Encoding.UTF8.GetBytes(password);
            byte[] byteHash = hashValue.ComputeHash(bytes);

            hashValue.Clear();

            return (Convert.ToBase64String(byteHash));
        }
开发者ID:TatianaRadkevich,项目名称:implementacion-proyectofinal2011,代码行数:15,代码来源:Usuario.cs


示例18: Encriptar

 public static string Encriptar(string valor)
 {
     string clave;
     System.Security.Cryptography.SHA1CryptoServiceProvider provider = new System.Security.Cryptography.SHA1CryptoServiceProvider();
     byte[] bytes = System.Text.Encoding.UTF8.GetBytes(valor);
     byte[] inArray = provider.ComputeHash(bytes);
     provider.Clear();
     clave = Convert.ToBase64String(inArray);
     return clave;
 }
开发者ID:paul33868,项目名称:Seguridad,代码行数:10,代码来源:cEncriptacion.cs


示例19: FileNameToSHA1Bytes

        // used by?
        public static byte[] FileNameToSHA1Bytes(this string Input)
        {
            var SourceHash = default(byte[]);

            var h = new System.Security.Cryptography.SHA1CryptoServiceProvider();

            using (var f = File.OpenRead(Input))
                SourceHash = h.ComputeHash(f);

            return SourceHash;
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:12,代码来源:SHA1CryptographyExtensions.cs


示例20: getHash

 public static string getHash(Object input)
 {
     // generate a unique id for an arbitrairy object
     MemoryStream memoryStream = new MemoryStream();
     System.Runtime.Serialization.Formatters.Binary.BinaryFormatter binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
     binaryFormatter.Serialize(memoryStream, input);
     System.Security.Cryptography.SHA1CryptoServiceProvider sha = new System.Security.Cryptography.SHA1CryptoServiceProvider();
     byte[] hash = sha.ComputeHash(memoryStream.ToArray());
     string str = Convert.ToBase64String(sha.Hash);
     return str;
 }
开发者ID:arendvw,项目名称:ExportTools,代码行数:11,代码来源:Tools.cs



注:本文中的System.Security.Cryptography.SHA1CryptoServiceProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Security.PermissionSet类代码示例发布时间:2022-05-24
下一篇:
C# Cryptography.RNGCryptoServiceProvider类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap