in reply to Can I abstract these blocks into a function call?
The main difference between the two blocks seems to be the use of $s1 / $sha1 vs. $s256 / $sha256, and some places where you need the substring "1" vs. "256" as part of something else.
So why not use two variables named $s / $sha (instead of the four you have now), and pass the SHA type (1, 256,...) to the routine, assigning it to another variable, e.g. $sha_type, which you can then interpolate as required?
|
|---|