diff options
Diffstat (limited to 'examples/hashtest/hashtest.cpp')
-rw-r--r-- | examples/hashtest/hashtest.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/hashtest/hashtest.cpp b/examples/hashtest/hashtest.cpp new file mode 100644 index 0000000..917c396 --- /dev/null +++ b/examples/hashtest/hashtest.cpp @@ -0,0 +1,25 @@ +#include"qca.h" +#include<stdio.h> + +int main(int argc, char **argv) +{ + TQCA::init(); + TQCString cs = (argc >= 2) ? argv[1] : "hello"; + + if(!TQCA::isSupported(TQCA::CAP_SHA1)) + printf("SHA1 not supported!\n"); + else { + TQString result = TQCA::SHA1::hashToString(cs); + printf("sha1(\"%s\") = [%s]\n", cs.data(), result.latin1()); + } + + if(!TQCA::isSupported(TQCA::CAP_MD5)) + printf("MD5 not supported!\n"); + else { + TQString result = TQCA::MD5::hashToString(cs); + printf("md5(\"%s\") = [%s]\n", cs.data(), result.latin1()); + } + + return 0; +} + |