IndexCalculator.php 611 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace ACES\Common;
  3. use ACES\Common\Exception\InsufficientSaltLengException;
  4. use ACES\Common\Exception\ArgumentNullException;
  5. class IndexCalculator
  6. {
  7. public static function sha256Index($pt, $salt){
  8. if($pt == NULL){
  9. throw new ArgumentNullException("Input is null for sha256Index function.");
  10. } elseif ($salt != NULL && strlen($salt) >= 16){
  11. $data = $pt.$salt;
  12. $md = hash("sha256", $data, TRUE);
  13. return $md;
  14. } else{
  15. throw new InsufficientSaltLengException("Salt length is too short.");
  16. }
  17. }
  18. }