I want to use a column that contains the string encoded with base64_encode()
function as primary key. But I couldn't get to learn that if same string gets different values when encoded with base64_encode()
.
Should I check the key existence with using encoded string in sql queries or should I get all values from DB and decode them one by one to see if that key exist? That depends on knowing if base64_encode()
function always creates the same output for given string. Does it?
Thanks in advance.
Yes, the function base64_encode() always produces the same output for a given string. This is called deterministic function or deterministic algorithm.
http://en.wikipedia.org/wiki/Deterministic_algorithm
base64 encoding always encodes data the same way, note that original encoding of string can yield in different base64 encoding.
Why on earth anyone would use a base64 encoded strings as PK beats me though
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With