1

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.

1

2 Answers 2

1

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.)

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.