title: postgresql bitwise XOR operation
body: <p>So i want to XOR on hexadecimal
  so i do this</p>
  
  <pre><code>select X'4e20' # X'4521'; --the output is 0000101100000001
  </code></pre>
  
  <p>but the thing is i wanna do XOR binary with hexa or integer with hexa or integer with binary, so i try to do this</p>
  
  <pre><code>select X(select to_hex(6700::bit(16))) # X'4F21';
  </code></pre>
  
  <p>this query will produce error result </p>
  
  <pre><code>[Err] ERROR:  syntax error at or near "select"
  LINE 2: select X(select to_hex(6700::bit(16))) # ...
  </code></pre>
  
  <p>So how can i do this that? and is it possible to xor an Ascii on postgresql?
  and i want to know how to :</p>
  
  <p>1.convert binary to integer</p>
  
  <p>2.convert hexa to binary vice versa</p>
  
  <p>3.convert hexa to integer</p>
  
  <p>4.conver ascii to integer</p>
  
  <p>this is Bit String Functions and Operators official from postgresql
  <a href="https://www.postgresql.org/docs/9.4/static/functions-bitstring.html" rel="nofollow noreferrer">https://www.postgresql.org/docs/9.4/static/functions-bitstring.html</a></p>