zoukankan      html  css  js  c++  java
  • MD5加密算法

    说明:本文介绍的内容就是怎么把一个字符串转换为MD5加密字符串

    1、界面设计
    两个文本框
    原字符串输入文本框(textbox ,name:txtString)
    MD5加密字符串文本框(textbox ,name: txtMD5)

    转换按钮(button,text:‘转换’,name:btChange)

    2、后台代码

    开发工具visual studio 2010 c#语言

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Security.Cryptography;
    
    namespace FrMD5
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void btChange_Click(object sender, EventArgs e)
            {
                txtMD5.Text = GetMD5(txtString.Text.Trim());
            }
            public static string GetMD5(string st)
            {
                MD5 md5 = new MD5CryptoServiceProvider();
                byte[] t = md5.ComputeHash(Encoding.GetEncoding("utf-8").GetBytes(st));
                StringBuilder sb = new StringBuilder(32);
                for (int i = 0; i < t.Length; i++)
                {
                    sb.Append(t[i].ToString("x").PadLeft(2, '0'));
                }
                return sb.ToString();
    
            }
        }
    }
    View Code
  • 相关阅读:
    null和undefined的区别
    "NetworkError: 404 Not Found fontawesome-webfont.woff?v=4.0.3
    php字符串
    php数组
    Oracle 和 MySQL的区别(不完整)
    拦截器和过滤器的区别
    SpringMVC和Struts2的区别
    Redis的介绍
    SpringBoot入门(2)
    SpringBoot入门(1)
  • 原文地址:https://www.cnblogs.com/net064/p/8004619.html
Copyright © 2011-2022 走看看