zoukankan      html  css  js  c++  java
  • DESCryptoServiceProvider

            public static byte[] DESEncrypt(byte[] data, byte[] sKey)
            {
                return DESEncrypt(data, sKey, sKey);
            }
            /// <summary>
            /// CBC-DES加密
            /// </summary>
            public static byte[] DESEncrypt(byte[] data, byte[] key, byte[] iv)
            {
                //注:已省略检查参数合法性等代码,以缩短帖子长度
                byte[] result = null;
                using (DES des = new DESCryptoServiceProvider() { Key = key, IV = iv })
                {
                    des.Mode = CipherMode.ECB;
                    des.Padding = PaddingMode.None;
                    result = des.CreateEncryptor().TransformFinalBlock(data, 0, data.Length);
                }
                return result;
            }
            public static byte[] DESDecrypt(byte[] data, byte[] sKey)
            {
                return DESDecrypt(data, sKey, sKey);
            }
            /// <summary>
            /// CBC-DES解密
            /// </summary>
            public static byte[] DESDecrypt(byte[] data, byte[] key, byte[] iv)
            {
                //注:已省略检查参数合法性等代码,以缩短帖子长度
                byte[] result = null;
                using (DES des = new DESCryptoServiceProvider() { Key = key, IV = iv })
                {
                    des.Mode = CipherMode.ECB;
                    des.Padding = PaddingMode.None;
                    result = des.CreateDecryptor().TransformFinalBlock(data, 0, data.Length);
                }
                return result;
            }
  • 相关阅读:
    Tomcat部署项目
    正则表达式
    文件的上传和下载
    实现扫码登陆
    onepill Android端
    部署SpringBoot到阿里云
    Gson
    HTML自动刷新页面
    Spring Data JPA根据属性名查询
    Spring Date JPA实现增删改查
  • 原文地址:https://www.cnblogs.com/shiningrise/p/5716745.html
Copyright © 2011-2022 走看看