summaryrefslogtreecommitdiffstats
path: root/kwallet/backend/tests/testsha.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kwallet/backend/tests/testsha.cpp
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kwallet/backend/tests/testsha.cpp')
-rw-r--r--kwallet/backend/tests/testsha.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/kwallet/backend/tests/testsha.cpp b/kwallet/backend/tests/testsha.cpp
new file mode 100644
index 000000000..70879f015
--- /dev/null
+++ b/kwallet/backend/tests/testsha.cpp
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "sha1.h"
+
+
+int main() {
+SHA1 *sha1;
+unsigned char data[] = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
+unsigned long et[] = {0x11223344};
+int rc;
+
+ printf("%d: 0x11 == %d and 0x44 == %d\n", ((unsigned char *)et)[0],
+ 0x11, 0x44);
+ sha1 = new SHA1();
+
+ if (!sha1->readyToGo()) {
+ printf("Error: not ready to go!\n");
+ return -1;
+ }
+
+ printf("About to process [%s]\n", data);
+ rc = sha1->process(data, strlen((char *)data));
+
+ if (rc != strlen((char *)data)) {
+ printf("Error processing the data. rc=%d\n", rc);
+ } else printf("Done.\n");
+
+const unsigned char *res = sha1->getHash();
+
+ if (res) {
+ for (int i = 0; i < 20; i++) {
+ printf("%.2X", *res++);
+ if (i>0 && (i-1)%2 == 0) printf(" ");
+ }
+ printf("\n");
+ } else printf("Error - getHash() returned NULL!\n");
+
+ delete sha1;
+}
+
+
+