惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
About on SuperTechFans
Y
Y Combinator Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
aimingoo的专栏
aimingoo的专栏
I
InfoQ
C
Check Point Blog
IT之家
IT之家
MyScale Blog
MyScale Blog
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
Last Week in AI
Last Week in AI
GbyAI
GbyAI
P
Proofpoint News Feed
量子位
Stack Overflow Blog
Stack Overflow Blog
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
B
Blog
T
The Blog of Author Tim Ferriss
H
Help Net Security
云风的 BLOG
云风的 BLOG

博客园 - 祥子哥哥

纪念一下我的20年的博客园。 [转]OPC.Client for DA and UA 使用C#开发库UcAsp.OPC.Client使用案例 推荐一个.Net的轻型RPC服务UcAsp.RPC Lucene.Net Kmeans++算是DONet实现 tinymce上传文件插件。 C#中图片处理中定义显示区域[或者可以称为蒙板效果] C#生成的图片如何设置DPI Jpg保存图片确认质量 Flex在子控件操作父窗口函数 Flex 不同 application 之间传参数(转) - 祥子哥哥 如何在DropDownList第一項加入新項目 2003服务器中出现"请求的资源在使用中"错误的解决方法 如何在.Net中访问MySQL数据库 MS SQL日志清理代码 Server Application Error Javascript检测Flash插件是否安装及版本号 最近ASP.NET WAP开发的一些情况! 数据库备份
刚刚写的一个加密算法
祥子哥哥 · 2005-09-13 · via 博客园 - 祥子哥哥

using System;

namespace UcAspClass
{
    
/// <summary>
    
/// Encrypt 密码加密算法
    
/// http://www.hzren.net  http://www.ucasp.net
    
/// 作者:QQ 36279010
    
/// </summary>

    public class Encrypt
    
{
        
public Encrypt()
        
{
            
//
            
// TODO: 在此处添加构造函数逻辑
            
//
        }

        
public static string encrypt(string word)
        
{
            
string Password=null;
            
int CodeLen=30;
            
int CodeSpace;
            
double NewCode;
            
byte[] chr={21};
            CodeSpace
=CodeLen-word.Length;
            
if(CodeSpace>=1)
            
{
                
for(int i=0;i<CodeSpace;i++)
                
{
                    word
=word+System.Text.Encoding.Default.GetChars(chr)[0].ToString();
                }

            }

            NewCode
=1;
            
int Been;
            
for(int i=0;i<CodeLen;i++)
            
{
                Been
=CodeLen+System.Text.Encoding.Default.GetBytes(word)[i]*(i+1);
                
                NewCode
=NewCode*Been;                
            }

            word
=NewCode.ToString();
            
string newcode=null;
            
for(int i=0;i<=word.Length-3;i++)
            
{
                newcode
=newcode+Hex(word.Substring(i,3));
            }

            newcode
=newcode=newcode+Hex(word.Substring(word.Length-2,2));
            newcode
=newcode=newcode+Hex(word.Substring(word.Length-1,1));
            System.Web.HttpContext.Current.Response.Write(newcode);
            
for(int i=19;i<newcode.Length-18;i=i+2)
            
{
                Password
=Password+newcode.Substring(i,1);
            }

            
return Password;
            
        }


    
/// <summary>
    
/// Hex转换为16进制结果
    
/// </summary>
    
/// <param name="word">我懒数据转换就用了string 但是一定数值</param>
    
/// <returns>16进制结果</returns>

        private static string Hex(string word)
        
{
            
string CfsCode="";
            
for(int i=0;i<word.ToString().Length;i++)
            
{
                CfsCode
=CfsCode+System.Text.Encoding.Default.GetBytes(word.ToString())[i].ToString();
                
            }

            
return Convert.ToInt64(CfsCode).ToString("X");
        }

    }

}

发表于 2005-09-13 15:57  祥子哥哥  阅读(367)  评论(0)    收藏  举报