Reputation: 14286
I have the following code:
<html>
<head>
</head>
<body>
<!-- some more CSHTML code here -->
<script src="https://js.braintreegateway.com/v1/braintree.js"></script>
<script>
var braintree = Braintree.create("SOME RANDOM KEY");
braintree.onSubmitEncryptForm('braintree-payment-form');
</script>
</body>
</html>
I want to be able to do the script without revealing the key string in the source. I have a key, but I don't want it to be revealed. Is there a safe and secure way to access a string by reference (preferably from a C# file)? Sort of like:
<script>
var braintree = Braintree.create(somefile.getString("string_key"));
braintree.onSubmitEncryptForm('braintree-payment-form');
</script>
Upvotes: 0
Views: 283
Reputation: 4603
If the code runs on the client, the key cannot be completely secure. A determined user could monitor network traffic and watch for the key when it arrived, or do one of 100 other things to compromise the key.
Upvotes: 2