the crypto used is from the console itself, a key called the eid root key is used (this key is stored inside the perconsole metldr) with a couple of keyseeds to generate either cbc or xts keys which will, in turn, decrypt the hdd.
if you clone a working disc to another, it will behave the same way (obviously with an ssd you'll have much faster speed but it'll also deteriorate faster since the ps3 doesn't support TRIM natively)
with the ps4 it's a similar method (but instead of having one master key, two keys are used, one by samu, and the other by the southbridge)
the samu key handles partitions like system, system_ex and system_data, while the southbridge key handles partitions like user, update and eap_vsh.
older ps4 models (such as CUH-1000 and 1100) use a static iv offset for the keys (0 in this case)
later models (such as CUH-1200 and above) use an iv offset that is calculated by subtracting the index of the device by 1 and left shifting by 32 (for example, for the user partition, this would be 27-1 << 32)
crypto for the ps3 device can be found here
https://github.com/Sorvigolova/ps3encdec/
and here
https://github.com/aerosoul94/PS-HDD-Tools
crypto for the ps4 device can be found here
https://github.com/zecoxao/ps4encdec
and here
https://github.com/aerosoul94/PS-HDD-Tools/
for ps3 crypto only the root key is required. for ps4 crypto (as of now we can only obtain the southbridge key), the southbridge key can be obtained either via a kernel dump (this is the easiest way for a hackable console) or via the ps4 hdd script by anonymous and an sflash dump
the offsets for the key location on the kernel can be found here
https://github.com/Ps3itaTeam/ps4-kexec/blob/9.00/magic.h
under the name kern_off_eap_hdd_key
the hdd script can be found in psx-place (search for the words ps4 hdd script)