zoukankan      html  css  js  c++  java
  • 生成随机密码

    导入下面的命名空间

    using System.Security.Cryptography;

    ==============代码=====================

            protected string RndPwd()
            {
                int[] arr = new int[]{ 1, 2, 3, 4, 5, 6, 7, 8, 9,6,6,8,8,9,9,1 };

                var r = new RNGCryptoServiceProvider();
                var bytes = new byte[arr.Length * 2];
                r.GetBytes(bytes);
               
                for (int i = 0; i < bytes.Length; i+=2)
                {
                    int tmp = 0;

                    int index1 = bytes[i] % arr.Length;
                    int index2 = bytes[i+1] % arr.Length;
                   
                    tmp=arr[index1];
                    arr[index1] = arr[index2];
                    arr[index2] = tmp;

                }
                return arr.Aggregate("",(total,ent ) => total += string.Format("{0}", ent)).Substring(0,6);
            }

  • 相关阅读:
    js设计模式(一)---单例模式
    JavaScript---设计模式总结
    js设计模式---单例模式
    js设计模式---工厂模式
    react学习笔记01
    css常用布局
    js 继承
    vue路由动态加载
    vue 项目总结
    css文字两端对齐
  • 原文地址:https://www.cnblogs.com/wdfrog/p/2107131.html
Copyright © 2011-2022 走看看