For this challenge, write a function that encrypts phone numbers. The method should hide the last six digits of each phone number.
Example 1 (Usi...
For further actions, you may consider blocking this person and/or reporting abuse
CSS
Another trickery with CSS: with no prechecks and assuming the phone number is valid, add the class "hide-phone-number" to the element and the last six digit will turn into Xs.
Ah, this is like people making the text background black on PDF documents and being surprised when people can still just copy & paste the original contents out of the "redacted" document.
It's exactly that :P
CSS assassin spotted
Outstanding move
JavaScript
But it could be any language that supports look-aheads in regular expressions 😉
This is not "encryption".
I usually don't get caught up on semantics, but I'm with you on this one. Idk why not-encrypted encryption irks me 🤷♀️
Me: okay, cool. Code review almost passed, but can you encrypt that one var?
Jr, 2 days later: here you go, I md5'd it.
Me: 🥺🤯💀⚰️💔
Well depends on the definition of "Encryption". If encryption means that you are hide information from not allowed authorities and you say no one is allowed to see these numbers, than this is encryption.
Err, no. You don't get to pick your own definition for words.
Encryption is "the process of converting information or data into a code, especially to prevent unauthorized access". The main point being, it can be decrypted. You can't decrypt data that has been deleted.
If you want to remove information it's called e.g. "redacting" or "obscuring".
"Encryption is the process of converting data to an unrecognizable or "encrypted" form. It is commonly used to protect sensitive information so that only authorized parties can view it." (techterms.com/definition/encryption)
"In cryptography, encryption is the process of encoding a message or information in such a way that only authorized parties can access it and those who are not authorized cannot." (en.wikipedia.org/wiki/Encryption)
I would guess there are multiple definitions and not the one and only! I would not say that encryption is wrong in this context, but "data anonymization" would be the better wording here.
"so that only authorized parties can view it" - you can't view it if you can't decrypt it
"encoding a message or information in such a way that only authorized parties can access it" - authorized parties can't decode XXX-XXXX
These are all the exact same thing.
Today I'm folding the other way around. I've chosen not to validate the number format because I didn't want to spend the entire evening building a regex that matched all possible formats I can think of.
There no package for phone numbers?
Using a library kinda defeats the purpose of these exercises, don't you think?
But what's the fun in that?
Yes I'm just asking 😄 of there are one I'll use it, working with phone number is a bit hardwork since others country had different types phone code.
Elixir:
Uses some bitstring pattern matching :)
JavaScript
Live demo on CodePen.
My python sol :
One liner (lambda exp) :
Python
gist.github.com/devparkk/266b9eb2f...