0

how to convert input field value to base64 encode or decode in angular js if any body know plz answered

I Want to convert input field value to base64

2 Answers 2

2

Use the btoa() function to encode:

console.log(btoa("test"));

To decode, you can use the atob() function:

console.log(atob("dGVzdA=="))

https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding

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

1 Comment

it's work on console but how to use with input field
0
<input type="text" [(ngModel)]="mymodel" class="form-controle" id="myid" />
var string = $('#myid').val();
var encodedString = btoa(string);
console.log(encodedString);
var decodedString = atob(encodedString);
console.log(decodedString);

1 Comment

Not Work Deepak Bro

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.