• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE Support
  • Sitemap
  • Contact Us
 

qca

base64test.cpp

Go to the documentation of this file.
00001 /*
00002  Copyright (C) 2004-2005 Brad Hards <bradh@frogmouth.net>
00003 
00004  Permission is hereby granted, free of charge, to any person obtaining a copy
00005  of this software and associated documentation files (the "Software"), to deal
00006  in the Software without restriction, including without limitation the rights
00007  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00008  copies of the Software, and to permit persons to whom the Software is
00009  furnished to do so, subject to the following conditions:
00010 
00011  The above copyright notice and this permission notice shall be included in
00012  all copies or substantial portions of the Software.
00013 
00014  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00017  AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00018  AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00019  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00020 */
00021 
00022 // QtCrypto has the declarations for all of QCA
00023 #include <QtCrypto>
00024 
00025 #include <QCoreApplication>
00026 
00027 #include <iostream>
00028 
00029 int main(int argc, char **argv)
00030 {
00031     QCoreApplication(argc, argv);
00032 
00033     // the Initializer object sets things up, and
00034     // also does cleanup when it goes out of scope
00035     QCA::Initializer init;
00036 
00037     // we use the first argument as the data to encode
00038     // if an argument is provided. Use "hello" if no argument
00039     QByteArray arg; // empty array
00040     arg.append((argc >= 2) ? argv[1] : "hello");
00041 
00042     // create our object, which does encoding by default
00043     // QCA::Base64 encoder(QCA::Encode); is equivalent
00044     QCA::Base64 encoder;
00045 
00046     // This does the actual conversion (encoding).
00047     // You might prefer to use encoder.encode(); and have
00048     // it return a QCA::SecureArray, depending on your needs
00049     QString encoded = encoder.arrayToString(arg);
00050 
00051     std::cout << arg.data() << " in base64 encoding is ";
00052     std::cout << encoded.toLatin1().data() << std::endl;
00053 
00054     // This time, we'll create an object to decode base64. We
00055     // could also have reused the existing object, calling
00056     // clear(); and setup(QCA::Decode); on it.
00057     QCA::Base64 decoder(QCA::Decode);
00058 
00059     // This time, we convert a QString into a QString
00060     QString decoded = decoder.decodeString(encoded);
00061 
00062     std::cout << encoded.toLatin1().data() << " decoded from base64 is ";
00063     std::cout << decoded.toLatin1().data() << std::endl;
00064 
00065     return 0;
00066 }
00067 

qca

Skip menu "qca"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE Support

Skip menu "KDE Support"
  • akonadi
  • Decibel
  • grantlee
  • kdewin
  • phonon
  •     Backend
  • polkit-qt
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for KDE Support by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal