I need a code where you can enter an input, and by the press of a button, the string becomes a jumbled mess. Basically, i need it to do the following things with the string:
Add “t” at the end of it
Reverse the string
Switch the first 2 characters together (i. e. if the original is AbNzm, the encrypted one is bANzm)
very interesting request .
here is something I whipped up quickly.
var string = "text to encrypt"
// Add "t"
one = string + "t"
// Reverse the string
two = one.split("").reverse().join('')
// Switch the first 2 characters together
split = two.split("")
three = split[1] + split[0] + split.slice(1).join("")
var string = "ttpyrcne ot txet"
split = string.split("")
one = split[1] + split[0] + split.slice(1).join("")
two = one.split("").slice(0).join("")
three = two.split("").reverse().join('')
I mean, i wanna use it as an automated password generator for my website - so you cannot change your password… but all you do there is just post things, you cannot technically add any personal info there…
On a side note, bcrypt is one-directional. You can encrypt passwords, but the only verification method bcrypt offers is the compare function, which accepts two strings. This way, the database admin only sees the encrypted password, and can not decrypt and view the original password.
If you want two-directional encrypting, you can use the built-in module nodejs crypto. For Hacktoberfest I did a little bit of encryption, which you can see here.