File tree Expand file tree Collapse file tree 3 files changed +61
-4
lines changed
Expand file tree Collapse file tree 3 files changed +61
-4
lines changed Original file line number Diff line number Diff line change @@ -34,17 +34,24 @@ SWDIAG_CL = swdiag-cl
3434SWRAWRANDOM = swrawrandom
3535SWRNGSEQGEN = swrngseqgen
3636SAMPLE = sample
37+ SAMPLECPP = sample++
3738SAMPLE_CL = sample-cl
3839
3940
40- all : $(SAMPLE ) $(SWDIAG ) $(SWPERFTEST ) $(BITCOUNT ) $(SWRNG ) $(SWRAWRANDOM ) $(SWRNGSEQGEN ) $(SAMPLE_CL ) $(BITCOUNT_CL ) $(SWDIAG_CL ) $(SWPERFTEST_CL ) $(SWRNG_CL )
41+ all : $(SAMPLE ) $(SWDIAG ) $(SWPERFTEST ) $(BITCOUNT ) $(SWRNG ) $(SWRAWRANDOM ) $(SWRNGSEQGEN ) $(SAMPLE_CL ) $(BITCOUNT_CL ) $(SWDIAG_CL ) $(SWPERFTEST_CL ) $(SWRNG_CL ) $( SAMPLECPP )
4142
4243$(SAMPLE ) : $(SAMPLE ) .c $(OBJECTS )
4344 @echo
4445 @echo " Creating $( SAMPLE) ..."
4546 $(CC ) -c $(SAMPLE ) .c $(CFLAGS ) $(CLANGSTD )
4647 $(GPP ) $(SAMPLE ) .o $(OBJECTS ) -o $(SAMPLE ) $(LDFLAGS )
4748
49+ $(SAMPLECPP ) : $(SAMPLECPP ) .cpp $(OBJECTS )
50+ @echo
51+ @echo " Creating $( SAMPLECPP) ..."
52+ $(GPP ) -c $(SAMPLECPP ) .cpp $(CPPFLAGS )
53+ $(GPP ) $(SAMPLECPP ) .o $(OBJECTS ) -o $(SAMPLECPP ) $(LDCPPFLAGS )
54+
4855$(SWDIAG ) : $(SWDIAG ) .c $(OBJECTS )
4956 @echo
5057 @echo " Creating $( SWDIAG) ..."
@@ -130,7 +137,7 @@ swrng-cl-api.o:
130137
131138
132139clean :
133- rm -f * .o ; rm -fr $(SAMPLE ) $(SWDIAG ) $(SWPERFTEST ) $(BITCOUNT ) $(SWRNG ) $(SWRAWRANDOM ) $(SWRNGSEQGEN ) $(SAMPLE_CL ) $(BITCOUNT_CL ) $(SWDIAG_CL ) $(SWPERFTEST_CL ) $(SWRNG_CL )
140+ rm -f * .o ; rm -fr $(SAMPLE ) $(SWDIAG ) $(SWPERFTEST ) $(BITCOUNT ) $(SWRNG ) $(SWRAWRANDOM ) $(SWRNGSEQGEN ) $(SAMPLE_CL ) $(BITCOUNT_CL ) $(SWDIAG_CL ) $(SWPERFTEST_CL ) $(SWRNG_CL ) $( SAMPLECPP )
134141
135142install :
136143 install $(SWDIAG ) $(BINDIR ) /$(SWDIAG )
Original file line number Diff line number Diff line change 1+ /*
2+ * sample++.cpp
3+ * Ver. 1.0
4+ *
5+ * A sample C++ program that demonstrates how to retrieve random bytes
6+ * from a SwiftRNG device using SwiftRNG C++ API.
7+ *
8+ *
9+ */
10+
11+ #include < SwiftRngApi.h>
12+ #include < string>
13+ #include < iostream>
14+
15+
16+ using namespace swiftrng ;
17+
18+
19+ /* *
20+ * Main entry
21+ * @return int 0 - successful or error code
22+ */
23+ int main () {
24+
25+ SwiftRngApi api;
26+ unsigned char entropyBytes [10 ];
27+
28+ std::cout << " ---------------------------------------------------------------------------" << std::endl;
29+ std::cout << " --- Sample C++ program for retrieving random bytes from SwiftRNG device ---" << std::endl;
30+ std::cout << " ---------------------------------------------------------------------------" << std::endl;
31+
32+
33+ if (api.open (0 )) {
34+ std::cerr << api.get_last_error_log () << std::endl;
35+ return -1 ;
36+ }
37+
38+ if (api.get_entropy (entropyBytes, sizeof (entropyBytes))) {
39+ std::cerr << " Could not retrieve entropy from SwiftRNG device. " << api.get_last_error_log () << std::endl;
40+ api.close ();
41+ return -1 ;
42+ }
43+
44+ for (int i = 0 ; i < (int )sizeof (entropyBytes); ++i) {
45+ std::cout << " entropy byte " << i+1 << " : " << (int )entropyBytes[i] << std::endl;
46+ }
47+
48+ api.close ();
49+ return 0 ;
50+ }
Original file line number Diff line number Diff line change 11/*
22 * swrngseqgen.cpp
3- * Ver. 2.3
3+ * Ver. 2.4
44 *
55 * A program for generating random sequences of unique integer numbers based
66 * on true random bytes produced by a SwiftRNG device.
@@ -62,7 +62,7 @@ void printRandomSequence(int64_t *buffer);
6262 */
6363int main (int argc, char **argv) {
6464
65- std::cerr << " -------------------------------------------------------------------------------------------------" << std::endl;
65+ std::cout << " -------------------------------------------------------------------------------------------------" << std::endl;
6666 std::cout << " --- A program for generating random sequences of unique integer numbers using SwiftRNG device ---" << std::endl;
6767 std::cout << " -------------------------------------------------------------------------------------------------" << std::endl;
6868
You can’t perform that action at this time.
0 commit comments