Author: Aamir Hasan
It is possible to put an AJAX token. With Silverlight we get the System.Security.Cryptography name space on the client – before it was not very easy to encrypt a string without any plug-in (well, there are some implementations of Blowfish available in JavaScript).
Encrypt and Decrypt method given below,how to implement cryptography in Ajax.NET Professional.
public override string Encrypt(string json)
{
return Security.Encrypt(Security.GetHashKey("hans"), json);
}
public override string Decrypt(string jsoncrypt)
{
return Security.Decrypt(Security.GetHashKey("hans"), jsoncrypt);
}
With Silverlight youre able to use the html bridge between JavaScript and managed .NET code. Youll find an example in the Silverlight Quickstarts. The Silverlight C# code looks likes this:
public override string ClientScript
{
get
{
return @"AjaxPro.cryptProvider = {
encrypt : function(s) {
var SLPlugin = document.getElementById(""Xaml1"");
var strOut = SLPlugin.Content.SL_SMT.Encrypt(s);
return strOut;
},
decrypt : function(s) {
var SLPlugin = document.getElementById(""Xaml1"");
var strOut = SLPlugin.Content.SL_SMT.Decrypt(s);
return strOut;
}
};";
}
}
public class ScriptableManagedType
{
// Note: static methods are not allowed
[ScriptableMember]
public string Encrypt(string text)
{
return Security.Encrypt(Security.GetHashKey("hans"), text);
}
[ScriptableMember]
public string Decrypt(string text)
{
return Security.Decrypt(Security.GetHashKey("hans"), text);
client-side code youre able to encrypt strings in JavaScript with the help of System.Security. In the AjaxSecurityProvider created above you have to override the ClientScript property to let Ajax.NET Professional encrypt the JSON strings using Silverlight:
Author:
Aamir Hasan औथोर:
आमिर हसन أثر
أمير حسن .
cb6edf69-16f0-4488-93aa-c5e36c0925fc|0|.0
ALL, asp.net
ajax, asp.net, silverlight,