Is it possible to use $ _POST within sha1? or other type of encryption?

1

I'm doing form comparison using sha1 as follows

sha1($_POST['txtEmpresa'] + $_POST['txtFornecedor'] + $_POST['txtDocumento'] + $_POST['txtValor'] + $_POST['txtVencimento']);

Is there any way to reduce this code to look like this?

sha1($_POST);

or another form of encryption that meets this need? I already used md5 and it did not work either.

    
asked by anonymous 11.05.2017 / 16:37

2 answers

5

You can use the implode() function , but be careful about the variable $_POST can contain parameters that you do not want and that would lead to an error.

Example:

sha1(implode('', $_POST));
    
11.05.2017 / 16:44
3

One possibility is you will serialize the contents of $ _POST:

sha1(serialize($_POST));

And since you are comparing the value of two forms, it may be worthwhile to use a ksort ($ _ POST) before generating sha1 to ensure that the order of fields is the same as this you can change the value of the hash.

    
11.05.2017 / 19:37