Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sample use of libscrypt.a and docs
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#include "crypto_scrypt.h" | ||
|
||
/* Parameters controlling memory usage and CPU time. */ | ||
#define N 16384 | ||
#define r 8 | ||
#define p 1 | ||
|
||
/* How much data should scrypt return? */ | ||
#define OUTPUT_BUFLEN 8 | ||
|
||
int main() | ||
{ | ||
const char * passwd = "hunter2"; | ||
const char * salt = "DANGER -- this should be a random salt -- DANGER"; | ||
uint8_t output[OUTPUT_BUFLEN]; | ||
int exitcode; | ||
|
||
exitcode = crypto_scrypt((const uint8_t *)passwd, strlen(passwd), | ||
(const uint8_t*)salt, strlen(salt), N, r, p, | ||
output, OUTPUT_BUFLEN); | ||
|
||
/* Notify user of success / failure. */ | ||
if (exitcode == 0) | ||
printf("crypto_scrypt(): success\n"); | ||
else | ||
printf("crypto_scrypt(): failure %i\n", exitcode); | ||
|
||
return (exitcode); | ||
} |