客户端和服务器端的Asp.net C#加密/解密 [英] Asp.net C# Encryption/Decryption on Client and server Side

查看:79
本文介绍了客户端和服务器端的Asp.net C#加密/解密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生, 我在客户端上有用于加密的jquery解决方案,但它仅创建"MD5".

Sir, I have the jquery solution to encryption on the client side but it create "MD5" only.

我要在客户端添加盐腌的Md5加密 并在Asp.net 4.0和C#中的服务器端对其进行解密

I want Salted Md5 Encryption on the Clientside and Decrypt it at the Server Side in Asp.net 4.0 and C#

我的加密代码如下:

<script type="text/javascript">
    function chn() {
        var a = document.getElementById('txt1'); 
        var b = document.getElementById('txt2');
        var c = a.value; var d = $.md5(c);
        b.value = (d);
    }
</script>

我希望每次尝试都必须更改加密.

I want that encryption must be change on every attempt..

示例:abc的首次加密为xyz

Example : first time encryption of abc is xyz

再一次,如果我尝试使用名称"Abc",那么它应该创建另一个加密 并检查服务器端.

and again if I will try with that name "Abc" then it should create another Encryption and check on server Side.

请帮帮我

推荐答案

MD5是哈希,不是加密机制.哈希从本质上来说是有损失的,并且多个输入可以(并且根据信鸽原理,绝对)产生相同的输出.

MD5 is a hash, not an encryption mechanism. Hashes are by their very nature lossy, and multiple inputs can (and by virtue of the pigeonhole principle absolutely will) produce the same outputs.

运行MD5就像计算一个单词中的元音数量一样.如果我告诉您一个单词中有4个元音,并要求您告诉我原始单词是什么,那么您根本就没有足够的信息来给我正确的答案.您也许可以找到其中有4个元音的某个单词,但是您不知道所找到的单词是否是 my 个单词.也许是,也许不是.从数学上讲,这是不可能的.

Running MD5 works like counting the number of vowels in a word. If I tell you that a word has 4 vowels in it, and ask you to tell me what the original word was, you simply don't have enough information to give me the the correct answer. You may be able to find some word that has 4 vowels in it, but you won't know whether the word you found was my word. Maybe it is, maybe it isn't. It's mathematically impossible for you to tell.

MD5以相同的方式工作.您将丢弃大量信息,可能的千兆字节或TB级的信息,而只生成一个16字节的摘要.

MD5 works the same way. You're throwing away tons of information, possible gigabytes or terabytes of information, and producing instead a single 16-byte summary.

从本质上讲,这是一个固有的单向过程.

It is, by intention, an inherently one-way process.

这篇关于客户端和服务器端的Asp.net C#加密/解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆