Skip to content

Commit 642ef9a

Browse files
committed
having issue while decrypted text
1 parent b7fca8a commit 642ef9a

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

text_to_emoji/js/script.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var data = "";
44
// btnClicking();
55
// })
66

7+
// localStorage.clear();
78
function encryption() {
89
document.querySelector("#encrypt-btn").addEventListener("click", function () {
910
// get the password
@@ -22,7 +23,7 @@ function encryption() {
2223

2324
// convert it into imojis
2425
str.forEach((ele) => {
25-
data += `&#128${ele.charCodeAt()}`;
26+
data += `&#128${ele.charCodeAt()} `;
2627
});
2728

2829
// console.log(addData);
@@ -45,7 +46,7 @@ function encryption() {
4546
addData = [{ 'pass': pass, 'text': input, 'data': data }];
4647
}
4748

48-
localStorage.setItem("data1", JSON.stringify(addData));
49+
localStorage.setItem(`data1`, JSON.stringify(addData));
4950
});
5051
}
5152

@@ -55,21 +56,25 @@ function decryption() {
5556
var data2 = '';
5657
var text2 = document.querySelector("#emoji-msg").value
5758
var finalPass = document.querySelector("#password").value;
58-
var user = JSON.parse(localStorage.getItem("data1"));
59+
var user = JSON.parse(localStorage.getItem(`data1`));
5960
// console.log(user)
6061
var str2 = text2.split("");
6162
str2.forEach(ele => {
62-
data2 += `&#${(ele.codePointAt(0))}`;
63+
data2 += `&#${(ele.codePointAt(0))} `;
64+
// data2 += `&#$(element.charCodeAt()) * Math.floor(Math.random() * 10)`;
6365
// console.log((element.charCodeAt()) * Math.floor(Math.random() * 10))
6466
});
6567
console.log(data2);
66-
var found;
68+
var found={};
6769
for(let i of user){
70+
console.log(i);
6871
if(i.data == data2){
6972
found = i;
70-
// console.log(i)
73+
console.log(i);
7174
}
7275
}
76+
console.log(found);
77+
console.log(data2);
7378
if (found.data === data2) {
7479
console.log("jay ho")
7580
document.querySelector(".result").style.display = `block`
@@ -84,6 +89,7 @@ function decryption() {
8489
})
8590

8691
}
92+
8793
function btnClicking() {
8894
document.querySelector(".decrypt").addEventListener("click", function () {
8995
document.querySelector(".decryption").style.display = "block";

0 commit comments

Comments
 (0)