# How to use Cipher API to decrypt signatures

We can retrieve the signature decrypting algorithm using two method:

1. By passing just player ID i.e.  http://api.gitnol.com/getAlgo.php?playerID=en_US-vflz7mN60
2. By passing player ID and signature format i.e. http://api.gitnol.com/getAlgo.php?playerID=en_US-vflz7mN60&sigformat=42.40

Developers can use any of them depending upon their requirement. But I recommend to use first method because first method includes the decrypting algorithm of most expected signature format.

The decrypting algorithm is in Python syntax. So developers working with PHP can use the following function to decrypt the signature using the algorithm obtained from first method:

```function decrypt(\$sig, \$algo){
\$funcarr = explode(' + ', \$algo);
\$decrypt = '';
foreach(\$funcarr as \$singfunc){
\$singfunc = substr(\$singfunc,2,-1);
\$operators = explode(':', \$singfunc);
if (sizeof(\$operators) == 1) {
\$decrypt .= \$sig[\$operators];
}
if (sizeof(\$operators) == 2) {
if(\$operators == ''){
\$decrypt .= substr(\$sig, 0 ,\$operators);
}
if(\$operators == ''){
\$decrypt .= substr(\$sig, \$operators);
}
if(\$operators >= 0 && \$operators >= 0){
\$decrypt .= substr(\$sig, \$operators, \$operators - \$operators);
}
}
if (sizeof(\$operators) == 3) {
if(\$operators == '' && \$operators == ''){
\$decrypt .= strrev(\$sig);
}
if(\$operators >=0 && \$operators == '' && \$operators != ''){
\$decrypt .= strrev(substr(\$sig, 0, \$operators + 1));
}
if(\$operators >=0 && \$operators >= 0 && \$operators != '' && \$operators != ''){
\$decrypt .= strrev(substr(\$sig, \$operators + 1, \$operators - \$operators));
}
}
}
return \$decrypt;
}```

Use above function to with proper params i.e. decrypt(\$signature, \$algorithm) and it will return the decrypted signature.

Hopefully I have considered each case of Python syntax. If anybody found any missing case then please contribute it.

More articles will follow soon on this section.

## One thought on “How to use Cipher API to decrypt signatures”

1. Pingback: My Homepage