How do I add/retrieve a password that contains £ using security add-generic-password and security find-generic-password?

security add-generic-password -a username -s "test" -w abc -U
security find-generic-password -a username -s "test" -w # output: abc
security add-generic-password -a username -s "test" -w abc£ -U
security find-generic-password -a username -s "test" -w # output: 616263c2a3
  • 1
    "616263c2a3" is the hex encoding of "abc£" (in UTF-8). Oct 8, 2020 at 19:29

2 Answers 2


As a workaround, I now encode and decode to base64:

security add-generic-password -a username -s "test" -w $(echo "abc£" | base64) -U
security find-generic-password -a username -s "test" -w | base64 --decode

I have today hit the same issue, I found the solution from the hint @gordon-davisson gave you. Here I create a password with a £ in it, try to retrieve it, get hex, then decode with xxd:

$ security add-generic-password -a Rumbles -s "Rumbles-Secret" -T /usr/bin/security -U
$ security add-generic-password -a Rumbles -s "Rumbles-Secret" -w "British£Password" -U
$ security find-generic-password -a Rumbles -s "Rumbles-Secret" -w
$ security find-generic-password -a Rumbles -s "Rumbles-Secret" -w | xxd -p -r

Using xxd you can decode the hex in to a string, but to tidy it up you would also want to strip the trailing %:

security find-generic-password -a Rumbles -s "Rumbles-Secret" -w | xxd -p -r | rev | cut -c 1- | rev

There may be other ways, I couldn't think of one without setting a variable...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .