Reputation: 219
I have a string that is encoded/encrypted using the following C# code:
public static string Encode(string text)
{
if (!Enabled)
return text;
return "~/Enc/" + System.Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(text));
}
How can I decode/decrypt it on the client side and get the original string before it was encoded/encrypted?
I've already tried atob(encodedString)
and it doesn't return the original value.
Upvotes: 1
Views: 1470
Reputation: 2896
you could always pass the client Url as a parameter in the viewmodel - ie.
public sting AjaxUrl {get;set;}
etc. ,then in model in the javascript
var link = '@Model.AjaxUrl'
(This may defeat the purpose of encryping the link though.)
Upvotes: 1
Reputation: 176
atob works fine if all you're doing is base-64 encoding something.
You're not, though.
atob isn't going to work because you wouldn't be getting the encoded string, you'd be getting ascii bytes of the string + the "~/Enc" text you're placing before it.
Upvotes: 1