sample-libscrypt-kdf.c 758 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <stdint.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include "scrypt-kdf.h"
  5. /* Parameters controlling memory usage and CPU time. */
  6. #define N 16384
  7. #define r 8
  8. #define p 1
  9. /* How much data should scrypt return? */
  10. #define OUTPUT_BUFLEN 8
  11. int
  12. main(void)
  13. {
  14. const char * passwd = "hunter2";
  15. const char * salt = "DANGER -- this should be a random salt -- DANGER";
  16. uint8_t output[OUTPUT_BUFLEN];
  17. int exitcode;
  18. /* Perform hashing. */
  19. exitcode = scrypt_kdf((const uint8_t *)passwd, strlen(passwd),
  20. (const uint8_t*)salt, strlen(salt), N, r, p,
  21. output, OUTPUT_BUFLEN);
  22. /* Notify user of success / failure. */
  23. if (exitcode == 0)
  24. printf("scrypt(): success\n");
  25. else
  26. printf("scrypt(): failure %d\n", exitcode);
  27. return (exitcode);
  28. }