MacOS – Using £ in Security Add-Generic-Password Command

command linemacospasswordSecurity

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

Best Answer

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