Page 1 of 1
header("ETag: " . sha1(date("YmdHis", getlastmod())));
Posted: Thu Mar 02, 2017 7:54 pm
by Vegan
Code: Select all
<?php header("ETag: " . sha1(date("YmdHis", getlastmod()))); ?>
I have been wondering about making a better plug-in for my websites to handle Google etc
the idea was HTTP 304 unchanged
so I know the headers needed etc
I was wondering, sha1 is deprevated so maybe the new sha3 is a better choice for a new plugin?
Re: header("ETag: " . sha1(date("YmdHis", getlastmod())));
Posted: Fri Mar 03, 2017 3:05 am
by requinix
Deprecated for cryptographic purposes. It's perfectly fine for regular hashes.
Re: header("ETag: " . sha1(date("YmdHis", getlastmod())));
Posted: Fri Mar 03, 2017 1:39 pm
by Vegan
does PHP 5.6 support sha3?
Re: header("ETag: " . sha1(date("YmdHis", getlastmod())));
Posted: Fri Mar 03, 2017 3:12 pm
by requinix
Built-in, no. Doesn't look like it is is available via the hash extension either.
Re: header("ETag: " . sha1(date("YmdHis", getlastmod())));
Posted: Fri Mar 03, 2017 6:41 pm
by Vegan
how about sha256 or sha512?
Re: header("ETag: " . sha1(date("YmdHis", getlastmod())));
Posted: Sat Mar 04, 2017 2:55 am
by requinix
Re: header("ETag: " . sha1(date("YmdHis", getlastmod())));
Posted: Sat Mar 04, 2017 6:30 pm
by Vegan
gives:
Code: Select all
Array
(
[0] => md2
[1] => md4
[2] => md5
[3] => sha1
[4] => sha224
[5] => sha256
[6] => sha384
[7] => sha512
[8] => ripemd128
[9] => ripemd160
[10] => ripemd256
[11] => ripemd320
[12] => whirlpool
[13] => tiger128,3
[14] => tiger160,3
[15] => tiger192,3
[16] => tiger128,4
[17] => tiger160,4
[18] => tiger192,4
[19] => snefru
[20] => snefru256
[21] => gost
[22] => gost-crypto
[23] => adler32
[24] => crc32
[25] => crc32b
[26] => fnv132
[27] => fnv1a32
[28] => fnv164
[29] => fnv1a64
[30] => joaat
[31] => haval128,3
[32] => haval160,3
[33] => haval192,3
[34] => haval224,3
[35] => haval256,3
[36] => haval128,4
[37] => haval160,4
[38] => haval192,4
[39] => haval224,4
[40] => haval256,4
[41] => haval128,5
[42] => haval160,5
[43] => haval192,5
[44] => haval224,5
[45] => haval256,5
)
but i see that sha256 is the only other choice for the syntax as I have it
Code: Select all
<?php header("ETag: " . sha256(date("YmdHis", getlastmod()))); ?>
Re: header("ETag: " . sha1(date("YmdHis", getlastmod())));
Posted: Sun Mar 05, 2017 2:42 am
by requinix
RTFM for how the hash extension works.
Spoiler: there is no "sha256" function.
Re: header("ETag: " . sha1(date("YmdHis", getlastmod())));
Posted: Sun Mar 05, 2017 6:22 am
by Vegan
WordPress has a hook to add a custom job, but I was wondering what I could conjure up
SHA-3 is done in C so it's not too hard to convert to a PHP function or class
Maybe I should look more into this are of WP