jquery手机插件进行加密/解密 [英] jquery mobile plugin for encryption/decryption

查看:302
本文介绍了jquery手机插件进行加密/解密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想加密和解密要作为URL参数传递的json对象。是否有一个jquery移动插件,为此目的提供加密和解密,因为我发现这个链接:



http://www.jquery4u.com/security/10-jquery-security/



但这有所有过时的插件。



如果在jquery插件中没有选项,那么我打算使用这个库。



http://crypto.stanford.edu/sjcl /



这是我最好的选择,因为我想要快速和轻量级的库,因为URL参数要求,还是我有一个更好的选择?

解决方案

BASE64



如果您想要一些也可以解密的基本加密,那么您应该使用 BASE64 加密/解密。



此插件可以作为 jQuerySDK ,如果您想了解更多信息,请查看 链接



用法:

  $。 toBASE64({
foo:'bar'
});

$ .toBASE64(['foo','bar']);

$ .toBASE64(12345);

$ .toBASE64('Lorem ipsum');



MD5 SHA1 XTEA



MD5 SHA1 当然要安全得多, BASE64 即可。不幸的是,它们仅用于编码。您可以使用 XTEA 。它的工作原理类似于 BASE64 ,但不同于 BASE64 你可以使用一个密钥来加密/解密你的字符串。



如果你想了解更多,请去这个 / p>

  // md5:
$()。crypt({method:md5,source:$(#短语)VAL()})。
// sha1:
$()。crypt({method:sha1,source:$(#phrase)。val()});

// xtea
$()。crypt({method:xteab64enc,source:$(#phrase)。val(),keyPass:$(#passPhrase ).VAL()});
$()。crypt({method:xteab64dec,source:xteab64,keyPass:$(#passPhrase)。val()});



编辑:



关于您的第一条评论如果你阅读我的答案,你会发现BASE64和XTEA是用来加密/解密你的字符串。如果你想查看jQuery,那么只有两个相关的可能性:Crypto-js和Stanford Crypto Library。他们是最好的javascript可以提供和差异就像可口可乐和百事可乐之间的区别。最终你会使用什么取决于真正要加密/解密的内容。对于不是密码的一切,都可以使用简单的解决方案,如BASE64或XTEA。密码与Crypto-js orStanford Crypto Library一起使用。


I want to encrypt and decrypt the json object to be passed as URL parameters. is there a jquery mobile plugin which provides the encryption and decryption for this purpose as I found this link :

http://www.jquery4u.com/security/10-jquery-security/

but this has all the outdated plugins.

If there is no option for me in jquery plugins, then I was planning to use this library.

http://crypto.stanford.edu/sjcl/

is this my best option as I want fast and lightweight library because of the URL parameters requirement or do I have a better option?

解决方案

BASE64

If you want some basic encryption that can be also decrypted then you should use plugin for BASE64 encryption/decryption.

This plugin can be found as a part of jQuerySDK and if you want to find out more take a look at this link.

Usage:

$.toBASE64({
    foo: 'bar'
});

$.toBASE64(['foo', 'bar']);

$.toBASE64(12345);

$.toBASE64('Lorem ipsum');

MD5, SHA1, XTEA

MD5 and SHA1 are of course much much more secure then BASE64. Unfortunately they are used only for encoding. Instead of them you can use XTEA. It works on a same principle like BASE64 but unlike BASE64 you can use a key to encrypt/decrypt your string.

If you want to find out more go to this link.

Usage:

//md5:
$().crypt({method:"md5",source:$("#phrase").val()});
//sha1:
$().crypt({method:"sha1",source:$("#phrase").val()});

//xtea
$().crypt({method:"xteab64enc",source:$("#phrase").val(),keyPass:$("#passPhrase").val()});
$().crypt({method:"xteab64dec",source:xteab64,keyPass:$("#passPhrase").val()});

EDIT :

Regarding your first comment if you read my answer you would find tha BASE64 and XTEA are used to encrypt/decrypt your string. If you want to look past jQuery then there are only 2 relevant possibilities: Crypto-js and Stanford Crypto Library. They are best javascript can provide and difference is just like difference between Coke and Pepsi. At the end what will you use will depend on what are really going to encrypt/decrypt. For everything that is not passwords go with easy solutions like BASE64 or XTEA. For passwords go with Crypto-js orStanford Crypto Library.

这篇关于jquery手机插件进行加密/解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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